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?
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.
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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With