Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New TypeScript React app using Vite - JSX.IntrinsicElements errors #13129

Closed
7 tasks done
rpasechnikov opened this issue May 9, 2023 · 11 comments
Closed
7 tasks done

Comments

@rpasechnikov
Copy link

Describe the bug

I'm trying out Vite with React TS and using their official documentation. The app builds and runs, however viewing it in VS Code shows a whole bunch of Property 'div' does not exist on type 'JSX.IntrinsicElements'.ts(2339) errors.

I've created a new React TS application using npx create-react-app my-app --template typescript and am not getting this issue.

Looking at Vite documentation once again, they've got a stackblitz link that exhibits the same issue, so this means that this is not my environment that's the problem.

Am I missing something? Surely this should not be a problem for official Vite documentation? Please note however, that I'm new to React and Vite.

Reproduction

https://stackblitz.com/edit/vitejs-vite-azsc25?file=src%2FApp.tsx&terminal=dev

Steps to reproduce

  1. Open Vite documentation https://vitejs.dev/guide
  2. Navigate to "Trying Vite Online" section
  3. Click on the react-ts link (https://stackblitz.com/edit/vitejs-vite-azsc25?file=src%2FApp.tsx&terminal=dev)
  4. Observe red underlines all over the place stating Property 'div' does not exist on type 'JSX.IntrinsicElements'.(2339)

System Info

Reproduceable both locally as well as on Firefox and Chrome browser, within Vite online react-ts example (see above)

Used Package Manager

npm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented May 9, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@rpasechnikov
Copy link
Author

Ok so it seeks that updating the tsconfig.json from "moduleResolution": "bundler" to "moduleResolution": "node" resolves this. I don't yet fully understand what this does, neither do I understand why Vite does not create a compatible configuration out of the box. I'll response if/when I found out more.

@ArnaudBarre
Copy link
Member

Is your VS code up to date? For me the latest version support TS 5 bundler resolution (I'm surprised they use the bundled version instead of the locally installed version...)

cc @patak-dev can you see on updating the version use on stackblitz?

@rpasechnikov
Copy link
Author

That ended up being it! Updating VS Code did the trick. Still unsure why the issue is present in the first place and why is it also present in the online sandbox environment, but I'm glad I've got a way forward.

Thanks for your help! :)

@bryanltobing
Copy link

i tried in stackblitz and the issue still exist

@tiborsaas
Copy link

I've ran into the same issue and indeed updating VSCode solved the validation error.

Upgraded from:

Version: 1.71.0 (system setup)

Version: 1.78.2 (system setup)

@Kiku-CN
Copy link

Kiku-CN commented May 16, 2023

The bundler module resolution is a new feature only work on Typescript 5.x.

Try to update latest typescript with the following command.

npm update typescript -g 

or

npm install typescript@latest -g

Ok so it seeks that updating the tsconfig.json from "moduleResolution": "bundler" to "moduleResolution": "node" resolves this. I don't yet fully understand what this does, neither do I understand why Vite does not create a compatible configuration out of the box. I'll response if/when I found out more.

@willxy
Copy link

willxy commented May 19, 2023

I'm using neovim not vscode, so the vscode update doesn't apply for me.

The typescript in my package.json that gets generated by vite was already v5 (5.0.2). I updated to typescript@latest which gave me 5.04, but that didn't help.

Updating vim plugins (PlugUpdate) and CoC plugins (CocUpdate) didn't seem to resolve it.

Changing my tsconfig.json "moduleResolution" from "bundler" to "node" or "nodenext" makes it work.

@ArnaudBarre
Copy link
Member

@willxy probably an issue with your IDE/plugins not supporting/using TS 5. Using moduleResolution node in the meantime is a good solution

@GavinSalcedo
Copy link

GavinSalcedo commented Jun 4, 2023

Ok so it seeks that updating the tsconfig.json from "moduleResolution": "bundler" to "moduleResolution": "node" resolves this. I don't yet fully understand what this does, neither do I understand why Vite does not create a compatible configuration out of the box. I'll response if/when I found out more.

This worked for me. Also I updated my VSCode to version 1.78

Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Jun 19, 2023
@patak-dev
Copy link
Member

FYI, the issue in StackBlitz with the react template has been fixed. See https://vite.new/react-ts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants