ZweiEuro
ZweiEuro4w ago

Intellisense not working for typescript react.

I ran this to create a new Vite React project: What I did:
deno run -A npm:create-vite@latest --template react-ts
deno install
deno task dev
deno run -A npm:create-vite@latest --template react-ts
deno install
deno task dev
But the type sensing was wrong, there also was no deno.json so i created one:
{
"imports": {
"react": "npm:react@^18.3.1",
"react-dom": "npm:react-dom@^18.3.1"
},
"compilerOptions": {
"lib": [
"dom"
],
"jsx": "react-jsx",
"jsxImportSource": "react",
"types": [
"npm:@types/react",
"npm:@types/react-dom"
]
}}
{
"imports": {
"react": "npm:react@^18.3.1",
"react-dom": "npm:react-dom@^18.3.1"
},
"compilerOptions": {
"lib": [
"dom"
],
"jsx": "react-jsx",
"jsxImportSource": "react",
"types": [
"npm:@types/react",
"npm:@types/react-dom"
]
}}
But the type sensing is still wrong, for very simple code like const [count, setCount] = useState<number>(0); VsCode does not detect count or setCount to be of type number, and it complains that useState has no type argument.
5 Replies
zor
zor4w ago
"Deno.disablePaths" : ["./src"] may be help If you have any better way to fix this. response it to me.
ZweiEuro
ZweiEuroOP4w ago
Thanks! That actually fixed it. But why does that help? So reading the settings, it disables deno but leaves denos built in TS analysis running ? Is there some drawback to doing this ?
CCPatriot
CCPatriot4w ago
Eh, I don't think that's actually solving the problem here. That would just tell VSCode to disable the Deno LSP for anything in ./src, which would mean VSCode would just fall back to the normal TypeScript LSP, which we know to be working correctly for this use case.
ZweiEuro
ZweiEuroOP4w ago
Yeah I thought so; is there another error with the default setup for that project?
zor
zor3w ago
Actually, there are other way to fix this error. You can use the guide from the link below to configuration deno.json file for your vscode project
https://docs.deno.com/runtime/fundamentals/configuration/
Deno
deno.json and package.json
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno