-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
vite
and @sveltejs/kit
types include @types/node
in the browser context
#9348
Comments
IIRC Vite relies on |
This is a general TypeScript problem - basically, once these types are imported somewhere, they are available/present everywhere. There's no way to constrain it to some files/file types. |
I don't think this is an upstream-blocked issue. Instead, it happens because all SvelteKit exports are grouped under the root From what I understand, types like To avoid this, I suggest moving the type definitions required in |
The vite config is already included in the tsconfig and with #12090 the same would happen for the Svelte config, so that wouldn't help much |
Yes, it is also necessary to separate tsconfig. |
In any case, this will be a breaking change, so I think it will be v3 if it is introduced. |
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: