Language-tools: Component usage in a Typescript project

Created on 6 Jul 2020  Â·  2Comments  Â·  Source: sveltejs/language-tools

We have a large-ish project that includes a Svelte component for in-browser debugging. We’ve been gradually migrating to Typescript, but hit a problem converting our client, because it imports the .svelte component file, which tsc doesn’t know how to handle. Is there already a way to solve this, might svelte2tsx be able to transform components to be compiled by tsc, or are there other plans for this situation? (We’re using rollup to compile the full project in case that’s relevant.)

Some links:

question

Most helpful comment

@dummdidumm Thanks for the explanation. Sorry — I saw the svelte2tsx package and thought that might be relevant. I did try moving rollup-plugin-svelte before typescript, but that didn’t seem to work. I’ll keep digging!

All 2 comments

This is probably the wrong place for this issue. This repo deals with the IDE experience and type checking experience, not bundling. Also it feels more like a question that would be fitting on Stackoverflow.

Looking at the config it seems rollup-plugin-svelte is called after typescript, which is the wrong order I guess.

svelte2tsx is not the solution to this because svelte2tsx does not produce executable code, it's just internally used to provide a better IDE experience using the TypeScript language service.

@dummdidumm Thanks for the explanation. Sorry — I saw the svelte2tsx package and thought that might be relevant. I did try moving rollup-plugin-svelte before typescript, but that didn’t seem to work. I’ll keep digging!

Was this page helpful?
0 / 5 - 0 ratings