'Typescript error TS2583 Cannot find name 'Set'
I have just started learning Typescript today and when I run tsc app.ts I get 11 errors but I thought I would start with the first. Tried updating tsconfig.json problems seem to be with node_modules.Any help would be appreciated. Thanks.
error states - ../../../node_modules/@types/react/index.d.ts:411:23 - error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"declaration": true,
"outDir": "./lib",
"strict": false,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["./src"],
"exclude": ["node_modules"]
Solution 1:[1]
In Visual Studio add the Microsoft.TypeScript.MSBuild package.
I also had this problem in a number of my SPAs in a .NET 5 core project. It seems like every time I added a Typescript file manually I would get these errors. I tried all of the different suggestions here on this site but nothing worked. So I paid attention the next time I added a typescript file maually. A pop up mentioned adding the Microsoft.TypeScript.MSBuild package. I did and all the errors went away.
Now, I don't use VSCode, so I don't know if it works the same or not but this worked in Visual Studio 2019.
Solution 2:[2]
try npm install @types/node
. Worked for me in VSCode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Meta_Programmer |