Replies: 2 comments
|
@types/react and @types/react-dom are what give you React autocomplete and hover docs inside the plain .jsx files. VS Code (and anything using tsserver) runs the TS language service on JS by default and reads @types straight from node_modules for autocomplete, hover, and JSX attribute completion, no tsconfig or checkJs required. The template itself shows it's editor-only: template-react ships them as devDeps but no tsconfig/jsconfig, so nothing type-checks your build (template-react-ts is the variant that carries tsconfig). I ran the TS 5.9 language service on the template's App.jsx both ways. With the types, hovering useState gives the full useState(...) signature and a offers the real typed attribute set (className, type, onChange, and so on). Pull @types out and the same query yields a bare import symbol plus a few in-scope identifiers, no real attribute suggestions. They're type-only devDeps, erased at build time, so safe to remove if you don't want the editor help. |
|
The So it is a deliberate editor-DX default, not a mistake. If you genuinely want zero type packages, you can delete both from |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Why does Vite's
reactandreact-compilertemplates include@types/reactand@types/react-domeven in the plain JS (non-TypeScript) variant? If someone wanted type support, aren't they supposed to use TypeScript?All reactions