TS2304: assembly cannot find name iterable in @ types / jquery

I am an old dog trying to learn new tricks (npm, TypeScript, etc.). I am using Visual Studio 2017 with TypeScript 2.5 (the project is set to "Last"). I have a very simple .NET Core 2.0 project, from which I just started working and added @ types / jquery (3.2.12) to my project, but it continues to complain that it cannot find "Iterable". I read a lot of posts on this subject and how to fix them, including:

TypeScript error: node_modules/@types/three/three-core.d.ts (767.24): TS2304 error: could not find the name "Iterable"

https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17239

Error TS-2304 - Cannot find the name "Iterable" in TypeScript when importing "jquery" into the ".ts" file

My current tsconfig.json contains:

{
  "compilerOptions": {
    "lib": [
      "dom",
      "es5",
      "es2015.iterable"
    ],
    "target": "es5"
  },
  "exclude": [
    "node_modules"
  ]
}

I tried every permutation of libs + target to no avail. I can get all kinds of other errors, but this kernel error never disappears. I spent more time trying to get TypeScript to work than it would take to write modules in plain ol JavaScript.

Is this a .NET Core project / template issue? How can I say that the IDE is viewing my tsconfig.json file (there are no such files in the project tree). Any help would be appreciated.

+4
source share
2 answers

, include tsconfig.json, . 3.2.1 jQuery 3.2.12 @types/jquery.

{
  "compileOnSave": true,
  "compilerOptions": {
    "lib": [ "dom", "es2015" ],
    "module": "commonjs",
    "sourceMap": true,
    "strict": true,
    "target": "es5"
  },
  "include": [
    "./Scripts/TypeScript/*"
  ],
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}
+1

, , jQuery , .

jQuery 1.10.2. default @types/jquery 3.2.16. 1, :

npm install @types/jquery@1.x

, 2.x 3.x

0

Source: https://habr.com/ru/post/1684983/


All Articles