Bei Tang
Bei Tang

Reputation: 17

node_modules/@types/babel _template/index.d.ts :16:28 - error TS2583: Cannot find name 'Set'

I followed this article to set up a TypeScript NPM package. The first time I ran npm run build(before install jest). It went really well. After that I installed jest and then I ran npm run build again, I’ve got a error message below:

tsc node_modules/@types/babel__template/index.d.ts:16:28 — error TS2583: Cannot find name ‘Set’. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.

16 placeholderWhitelist?: Set;

Found 1 error.

My node, npm, tsc version is: node -v // v8.12.0, npm -v // v6.4.1, tsc -v // v3.4.5

Here is tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "declaration": true,
    "outDir": "./lib",
    "strict": false
  },
  "include": ["./src"],
  "exclude": ["node_modules", "**/__tests__/*"]
}

I already excluded "node_modules" in tsconfig.json, how come tsc still ran node_modules?

Upvotes: 2

Views: 3678

Answers (3)

Honza P.
Honza P.

Reputation: 1242

In my case I did not change project anyhow (seen that in GIT changes). Just installed nodejs into Windows 10 via npm and this error message popped on me when compiling Web project of ASP.NET application (that has nothing to do with node_modules!). The only working solution that worked for me was delete and update package:

  1. npm i -D @types/node
  2. npm i @types/node

Upvotes: 2

Bei Tang
Bei Tang

Reputation: 17

tsconfig.json

By default all visible @types packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered visible; specifically, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on.

Upvotes: 0

Yevhen Laichenkov
Yevhen Laichenkov

Reputation: 8652

Try to add the "lib": ["es6"] or higher and change the "target": "es6" in the compilerOptions

"compilerOptions": {
  "target": "es6",
  "lib": ["es6"],
  "module": "commonjs",
  "declaration": true,
  "outDir": "./lib",
  "strict": false
}

Upvotes: 0

Related Questions