Intellij IDEA simultaneously recognizes Typescript method/function and marks it as non existing.

已回答

I have a problem regarding very strange behaviour of IntelliJ IDEA regarding core JS types in Typescript code files.

Here we see that forEach is simultaneously marked red and explained.

Autocomplete also suggests such method, while it being incorrect line above:

I have tried restarting TypeScript services, invalidating caches, changing TS config. Problem is always with core JS types - similar errors are for Number and Error constructors for example. All other types - defined by me or imported from node_modules are recognized correctly.

0

Which IDE and TypeScript versions do you use? Could you please share your tsconfig.json?

0

I managed to partially fix the issue by changing JavaScript language version to 5.1 and back to 6+. Somehow it fixed all method errors. I had only some type errors after it (for example Generator type was marked as an error while simultaneously having documentation). When I checked today those problems also went away - not sure how.

My setup:

IntelliJ IDEA 2024.1.4 (Ultimate Edition)

Build #IU-241.18034.62, built on June 20, 2024

"typescript": “4.8.4”

tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./target/",
    "sourceMap": true,
    "strict": true,
    "module": "commonjs",
    "target": "es6",
    "jsx": "react",
    "lib": ["DOM", "ES6"]
  }
}

 

0

请先登录再写评论。