skip to Main Content

I am using Visual Studio 2022. I created a new React project using React and ASP.NET Core template:

enter image description here

The code runs fine:

enter image description here

But I see the following error:

Error: TS2304 (TS) Cannot find name ‘ExtendableEvent’.

The error is shown on this file:

enter image description here

When I check the path, I can see that I have the following versions of TypeScript installed:

enter image description here

And this is what I have in packages.json:

enter image description here

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

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    I managed to resolve the issue by updating Visual Studio 2022 and also Installing TypeScript SDK.

    To Install TypeScript SDK:

    1. Run Visual Studio 2022 Installer, and click on Modify under Build Tools: enter image description here

    2. Choose Individual Components and Make Sure TypeScript SDK is installed. enter image description here

    This answer helped me to resolve the issue.


  2. 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 with v18.16.1 everything worked.

    enter image description here
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search