-
-
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
svelte-kit build swallows typescript errors #1536
Comments
This should probably be done in Vite's side, I remember Sapper can catch TS errors because it uses Rollup plugins. In the meantime, you can add a pre-build step to check for errors first "scripts": {
...
"build": "tsc --noEmit && svelte-kit build",
...
}, |
The build process itself will not run any type checking. You need to use svelte-check for that. Running |
As @dummdidumm says, but if you only want to catch errors in |
Right, forgot that you need a separate step to do the main thing that TypeScript was made for. That still really feels like an anti-pattern to me. |
I went back and re-read the reasoning behind not having preprocess do the type checking (sveltejs/svelte-preprocess#205), which is an unfortunate but ultimately sensible approach since the preprocessors work on isolated chunks so checks like unused variables wouldn't work. However, at the end of that issue it's mentioned that while the preprocessor is the wrong place for this type of check putting it in the loader/rollup plugin would make sense. I think that svelte-kit's The job of Besides, think how amazingly useful it would be for us TS devs if having a type error (or unused var, or any of the other errors tsc can check for) would pop up a Vite panel on the live site, like it does if you have an html error. That level of integration of tooling would be absolutely invaluable for rapid development, regardless of your choice of editor, and it comes with peace-of-mind as you'd no longer have to ask "did I remember to run |
Additionally I now realize that |
|
@dummdidumm Could you elaborate on why it would be wrong to do type checking in the build process? I (and many other people) feel it's wrong to not do it in the build step. I tolerated it when using svelte-preprocess via webpack/rollup due to the aforementioned technical limitations, but now that you have your own start-to-finish build command I see no reason to not have type checking built into the build step like every single other compiler does. |
Because doing |
Sure it's more explicit, but there's still a reason why tooling like |
|
This add svelte-check along with two validate scripts to the package.json if the user selects TS. This uncovered missing type definitions for the cookie package in the default template, which are now added as well if the user selects TS. Closes #1536
Describe the bug
Errors in .ts files are silently ignored when running
svelte-kit build
.Logs
N/A
To Reproduce
tsconfig.json
, such asstrictNullChecks
ornoUnusedLocals
, then write some code that breaks that rule. For example, settingnoUnusedLocals: true
then writinglet unusedVar = 42;
.svelte-kit build
Expected behavior
I expect that
svelte-kit build
would fail (exit != 0) and give a helpful error message. Instead it just silently succeeds, even though compiling the exact same code withtsc
correctly errors.Stacktraces
N/A
Information about your SvelteKit Installation:
N/A
Severity
Very annoying, means that I can't rely on the build process to catch errors so I have to spend extra time checking for them manually and also worry about an avoidable bug slipping through the cracks.
Additional context
N/A
The text was updated successfully, but these errors were encountered: