Re:Migrating from Vue 2 to Svelte
by pcthrowaway on Friday December 02, 2022 @08:39AM
(#33830272)
How is typescript support? I found that a bit lacking when I was using Svelte (and I otherwise love svelte)
[ Parent
| on HN ]
Typescript support in Svelte is one of the biggest problems with the framework I’ve encountered. We have a couple of production Svelte apps at my job and overall the frontend DX is excellent. However, not being able to use generically typed components is a big missing feature. We have a number of custom core components which work really well, but not being able to create a new component with something like MyTable = Table<User> feels like an oversight. Inside of the Table code we work around this shortcoming to appease tslint…
Overall though regular .ts code works well. We use it for all our API definitions and networking layer, and it’s been 1000x better than our former version built with jinja/jQuery.
I may be missing something (I haven't used Svelte, SvelteKit, or TypeScript much), this doesn't seem accurate. I was going to link to a direct example, but I'm not sure I understand exactly what you're looking for. More information here: https://github.com/ivanhofer/sveltekit-typescript-showcase
I added some more information in another reply, but Svelte has officially supported TypeScript for a couple years now. It provides some tooling to get started and there are also existing projects that may make certain things easier or more useful.
Announcement (some things have changed, surely): https://svelte.dev/blog/svelte-and-typescript
More info in the GitHub repo I linked to elsewhere.