-
Notifications
You must be signed in to change notification settings - Fork 151
TypeScript type imports #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a known limitation. edit: Just added a quick link regarding the limitation in the docs: https://github.com/sveltejs/svelte-preprocess/blob/master/docs/preprocessing.md#typescript---limitations |
I can fix this at TypeScript level for Svelte in the tsconfig via https://www.staging-typescript.org/tsconfig#importsNotUsedAsValues |
I think it's worth turning on there, but I'm not 100% if it runs in transpileOnly because it won't have a type system to back up its interpretation (so it's fine either way) |
This change seems to break my code which was working fine with version 1.0.2. If I understand you correctly, my code wasn't supposed to work actually? Or was it working because my typescript files only contain code which doesn't need to be preprocessed (e.g. no decorators, ...)? |
Your code used to work kinda by accident is mainly the point, the identifier |
Thanks for posting this. I also ran into this and didn;t want to add
|
Turning the "importsNotUsedAsValues" TS config value to "error". This will require us to use `import type` instead of `import` when we are importing a value that is only used as a type (and therefore that is dropped by the Typescript compiler). Why this change? This is a requirement to be able to use Svelte in the future. See sveltejs/svelte-preprocess#206 (comment)
Turning the "importsNotUsedAsValues" TS config value to "error". This will require us to use `import type` instead of `import` when we are importing a value that is only used as a type (and therefore that is dropped by the Typescript compiler). Why this change? This is a requirement to be able to use Svelte in the future. See sveltejs/svelte-preprocess#206 (comment)
I am quite often getting the error |
For some reason this was removed from the Typescript Limitations section, while this still is an issue. |
Currently you cannot import TypeScript types using standard
import {MyInterface} from 'mylib'
syntax but must useimport type {MyInterface} from 'mylib'
instead. This is a bit inconvenient and non-obvious since Vue and many others allow using the standard syntax, is this something that could be improved or is it a limitation of svelte?Refs sveltejs/template#146
The text was updated successfully, but these errors were encountered: