Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Cannot find name 'Set'

Tags:

typescript

I have simple ts file with a simple sum function that just simple add two numbers no Rocket Science here below

function sum(a,b){
    return a+b;
}

But when I run

tsc TypeScript.ts

I get this error below?

   ts 
    ../../../../node_modules/@types/react/index.d.ts:388: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.
    
    388         interactions: Set<SchedulerInteraction>,
                              ~~~
    
    
    Found 1 error.
    

How can i fix this error?

like image 856
john Avatar asked Feb 15 '20 21:02

john


People also ask

What does Cannot find name require?

To solve the "Cannot find name require" error, install the node types by running npm i -D @types/node . If the error is not resolved, you can use declare var require: any to declare require as a global variable in your project. The first thing you need to do is make sure you have typings for Node. js installed.

Can not find name react?

To solve the "Cannot find name" error in React typescript, use a . tsx extension for the files in which you use JSX, set jsx to react-jsx in your tsconfig. json file and make sure to install all of the necessary @types packages for your application.


Video Answer


1 Answers

I searched through StackOverflow and i found the answer. Just type this following command in the terminal

npm install @types/node --save-dev

Then the error will dissapear!

like image 113
john Avatar answered Oct 24 '22 07:10

john