vite
and @sveltejs/kit
types include @types/node
in the browser context
#9348
Labels
Milestone
vite
and @sveltejs/kit
types include @types/node
in the browser context
#9348
Describe the bug
my project has some code that's executed in the browser and other code that's executed by node, so i need to have
@types/node
installed. unfortunately, the generated.svelte-kit/tsconfig.json
includes files (such asambient.d.ts
andvite.config.ts
) that rely on node types.you can see this by disabling
skipLibCheck
the your project'stsconfig.json
then runningtsc
:(ommitted the rest of the errors but there's like 50)
after installing
@types/node
, typescript now incorrectly treats svelte code as if it's run by nodejs:(in nodejs,
setTimeout
returns aTimeout
object but in the browser it returns anumber
)adding
"typeRoots": []
and"types": []
intsconfig.json
does not help because@types/node
is still being included by files matched by theinclude
section in.svelte-kit/tsconfig.json
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-nxgj43?file=src%2Froutes%2F%2Bpage.svelte
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
vite.config.ts
, and@types/node
is needed for those files to be correctly type checked@playwright/test
depends on@types/node
so this issue is unavoidable if you select playwright in thenpm svelte create
menuThe text was updated successfully, but these errors were encountered: