Meteor-svelte with Typescript

Hello, I’m integrating Svelte into my Meteor project. I’m using the svelte:compiler and svelte packages. On the backend I’m using Typescript, the native Meteor version.

I’d like to take advantage of Typescript on the frontend too. Now Svelte just has included Typescript support as well. How do I do this? Does anyone know if there is an update underway of svelte:compiler and do I even need this?



I was wondering the same actually …


That’s enough backup for me to make it an issue on github svelte:compiler

1 Like

Here’s a PoC plugin built over zodern:melte with TS and SCSS support if you still wish to try: The trusted source for JavaScript packages, Meteor resources and tools | Atmosphere

I checked it out but but only got this:

modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:234 Uncaught Error: Cannot find module 'meteor/zodern:melte/hmr-runtime.js'
    at makeMissingError (modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:234)
    at Module.resolve (modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:249)
    at Module.moduleLink [as link] (modules.js?hash=5e33e7657f09c1af865ec3fed6444213081adbc4:303)
    at app.js?hash=3c916bc7f2a59d2f442273d903ad60ec932dd101:60
    at module (app.js?hash=3c916bc7f2a59d2f442273d903ad60ec932dd101:185)
    at fileEvaluate (modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:388)
    at Module.require (modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:270)
    at Module.moduleLink [as link] (modules.js?hash=5e33e7657f09c1af865ec3fed6444213081adbc4:310)
    at module (main.ts:1)
    at fileEvaluate (modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:388)
makeMissingError @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:234
Module.resolve @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:249
moduleLink @ modules.js?hash=5e33e7657f09c1af865ec3fed6444213081adbc4:303
(anonymous) @ app.js?hash=3c916bc7f2a59d2f442273d903ad60ec932dd101:60
module @ app.js?hash=3c916bc7f2a59d2f442273d903ad60ec932dd101:185
fileEvaluate @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:388
require @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:270
moduleLink @ modules.js?hash=5e33e7657f09c1af865ec3fed6444213081adbc4:310
module @ main.ts:1
fileEvaluate @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:388
require @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:270
require @ modules-runtime-hot.js?hash=d12281259a6cee99786429a66f76b05f13449c7f:310
(anonymous) @ app.js?hash=3c916bc7f2a59d2f442273d903ad60ec932dd101:229
hot-module-replacement.js?hash=22d8cfbe1ca1509fc13b6f268883287a7c6b3b6c:299 HMR: connected

Any progress? I’m exploring this as well

No. I think you have to use svelte - preprocessor and use that to compile typescript in svelte. Since that is done before svelte gets compiled itself, I don’t think there should be an issue with Meteor. I abandoned Typescript. It does away with all the Javascript advantages. For Meteor the refactoring is a pain. I figured I didn’t need schemas anymore for MongoDB, which is not true. I hate simple schema, but TS doesn’t take its place. I use check / Match now. Works well. Good luck!

1 Like

By now, yes. You have to use zodern:melte, svelte-preprocess, typescript through npm, to allow compiling Svelte script tags (), as well as typescript with Meteor (meteor add typescript). Key is to have the right versions of everything. Typescript with Meteor is 4.4.1, but I can’t find a normal one of this on npm, so I use 4.4.2. I’m also using Svelte 3.29.7. Found that one by trial and error.

Trialled and errored a bit further: Using Svelte 3.36.0 now.