You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run typecheck for client *and* server with nuxi typecheck #323
When running nuxi typecheck, only the client types are checked right now. Ideally, also the tsconfig.json of the server should be used and the nitro/server side should be checked!
Reacted by Estéban, Sebastian Langer and Andrew Russell
Reacted by gangan, Wind, Antoine Rey, rijenkii and Nicolas Payot
Hmm, maybe I'm testing incorrectly but the command seems to also typecheck server files in a local test project, can someone provide a minimal reproduction shows the lack of type checking on the nitro/server side? I'll use it to try and implement type checking if it is still lacking 🙏
It actually looks like typecheck only checks client files (does not use tsconfig.server.json) which means the server directory should be excluded, the errors in your reproduction shouldn't be thrown at all.
The server files are not being excluded as expected due to explicit imports/references by included files, which in this case are the auto import types generated by nitro (nuxt.d.ts > types/nitro.d.ts > types/nitro-imports.d.ts).
@danielroe
Should the nitro.d.ts types be included in the generated tsconfig.json or should these actually only be included in tsconfig.server.json?
The typecheck command needs may need to be changed to run two type checks, for client files and for server files, I can look into this, but we have to prevent the server files from being included in the client tsconfig.json (not sure how).
I have updated the reproduction and removed the additional alias config, running pnpm typecheck demonstrates server files are checked while tsconfig.server.json is not being used since it throws errors.
Activity
kaaax0815 commentedon Jan 17, 2025
Any status on this?
BobbieGoede commentedon Jan 17, 2025
Hmm, maybe I'm testing incorrectly but the command seems to also typecheck server files in a local test project, can someone provide a minimal reproduction shows the lack of type checking on the nitro/server side? I'll use it to try and implement type checking if it is still lacking 🙏
kaaax0815 commentedon Jan 19, 2025
I made one here for my use case
https://stackblitz.com/edit/server-typecheck-repro?file=nuxt.config.ts
I have to add the alias to the generated
tsconfig.jsonfor aliases to work. even tho it should be enough if its in thetsconfig.server.jsonBobbieGoede commentedon Jan 19, 2025
@kaaax0815
Thank you for the reproduction!
It actually looks like
typecheckonly checks client files (does not usetsconfig.server.json) which means the server directory should be excluded, the errors in your reproduction shouldn't be thrown at all.The server files are not being excluded as expected due to explicit imports/references by included files, which in this case are the auto import types generated by nitro (
nuxt.d.ts>types/nitro.d.ts>types/nitro-imports.d.ts).@danielroe
Should the
nitro.d.tstypes be included in the generatedtsconfig.jsonor should these actually only be included intsconfig.server.json?The
typecheckcommandneedsmay need to be changed to run two type checks, for client files and for server files, I can look into this, but we have to prevent the server files from being included in the clienttsconfig.json(not sure how).I have updated the reproduction and removed the additional alias config, running
pnpm typecheckdemonstrates server files are checked whiletsconfig.server.jsonis not being used since it throws errors.Related
vue-tscoverwrite server imports with app imports nuxt#29263