Reputation: 16607
I run tsc --noemit
to ensure the are no type errors in the codebase. Unfortunately, it does not seem to check .svelte files.
Is there a way to make it work? I can see the type errors in .svelte files open in VS Code, so I think it has to be possible somehow with existing tooling.
Also I'm using the official @rollup/plugin-typescript I'm aware there is also rollup-plugin-typescript2 which checks types on build and may be an alternative solution, but I prefer to not enforce types on build and check types separately as I currently do.
Upvotes: 5
Views: 1530
Reputation: 5426
Use svelte-check
for this: https://www.npmjs.com/package/svelte-check
tsc --noemit
only knows about TypeScript files, not Svelte files. svelte-check
fills that gap and is able to check both TS and Svelte files.
When using it with TypeScript the recommended way to run it is: svelte-check --tsconfig ./path/to/your/tsconfig.json
. Assuming your tsconfig.json
is in your project root and you run that from the root, do svelte-check --tsconfig ./tsconfig.json
. It's advised to install svelte-check
locally, so you can add a script
to your package.json
with the mentioned command.
Upvotes: 5