I am using Visual Studio 2022. I created a new React project using React and ASP.NET Core template:
The code runs fine:
But I see the following error:
Error: TS2304 (TS) Cannot find name ‘ExtendableEvent’.
The error is shown on this file:
When I check the path, I can see that I have the following versions of TypeScript installed:
And this is what I have in packages.json
:
How can I resolve this issue?
Update
I believe the issue here is that the error is raised on file under TypeScript/4.3 but in my package.json
the requirement for TypeScript is min: 4.9.5. However I am not sure how to change the TypeScript version?
My node.js version is 18.17
2
Answers
I managed to resolve the issue by updating Visual Studio 2022 and also Installing TypeScript SDK.
To Install TypeScript SDK:
Run Visual Studio 2022 Installer, and click on Modify under Build Tools:
Choose Individual Components and Make Sure TypeScript SDK is installed.
This answer helped me to resolve the issue.
I have a test in my side before and I also faced the error as yours, and I noticed that I didn’t use the latest version of nodejs so that I try to update the nodejs by uninstall the old SDK and install the new version, then the issue disappeared. But I didn’t remember the old version of my SDK, nor have a screenshot for the same error I met… So I try to reproduce but no luck to reproduce again.
What I can say is, when I start to test with
v15.9.0
, I can create the project through the template successfully, before that, I kept getting exception when creating the project. And I’m sure withv18.16.1
everything worked.