3 ms·
In my previous experience of "Svelte with Typescript", it merely remove the typings, no type checking at all. Try in below example, it print out '12' without t
by aabbcc1241 6y ago
In my previous experience of "Svelte with Typescript", it merely remove the typings, no type checking at all.
Try in below example, it print out '12' without type related error message.
<script lang="ts">
let a: number = '1';
let b: number = 2;
</script>
<p>
c = {a + b}
</p>
- aabbcc1241 6y agoAnother direction of using typescript based DSL languages that compiles to svelte code seems more maintainable. Checkout https://github.com/mistlog/svelte-draft https://github.com/mistlog/svelte-draft
- cetra3 6y agoI've just tried this using the starter project they provide in the blog post, and it does catch the error: The error returned is `Type '"1"' is not assignable to type 'number'.`
- aabbcc1241 6y agoThanks for pointing out. It's getting better overtime! I missed the existence of "svelte-check". I expected to see errors on the webpage like we usually see from angular/react/stencil. On svelte, the typescript error doesn't show up until you manually run svelte-check.
- benmccann 6y agoThe VS Code extension will surface type checking errors for you or if you want to surface them on the command line you can run https://www.npmjs.com/package/svelte-check https://www.npmjs.com/package/svelte-check