Itai Noam
Itai Noam

Reputation: 4145

Missing typescript declaration file in javascript

My project is mixed javascript and typescript files. That's my tsconfig.json file:

"compilerOptions": {
  "target": "es2017",
  "baseUrl": ".",
  "checkJs": false,
  "allowJs": true, 
  "noImplicitAny": true,
  "strictNullChecks": true,
  "experimentalDecorators": true,
  "jsx": "react",
  "esModuleInterop": true,
  "isolatedModules": false,
  "noEmit": true,
  "moduleResolution": "node",
  "skipLibCheck": true,
}

I keep getting in my javascript files (checkJs set to false):

Could not find a declaration file for module 'file1'. 'file1.js' implicitly has an 'any' type.ts(7016)

These errors show as 3 dots under the import statement and do not add to the error count in vscode problems panel.

Screenshot: enter image description here

Upvotes: 0

Views: 2609

Answers (1)

Rohith K P
Rohith K P

Reputation: 3551

If you are importing those JS files then use // @ts-ignore comment before the import line. TS compiler will skip the error checking for the next line.

//@ts-ignore
import * as something from 'file1';

Upvotes: 4

Related Questions