0

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

0

1 Answer 1

4

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';
Sign up to request clarification or add additional context in comments.

2 Comments

I do not want to ignore those errors. I am actually trying to understand why I get those errors in the first place.
@ItaiNoam You need to have a type declaration for your javascript module to not have those errors. You can read about it here => medium.com/@chris_72272/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.