-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Mixing value and type imports causes errors #2654
Comments
It works inside Svelte files, yes, but for SvelteKit, ironically it doesn't work in TS files. The reason is that Vite uses ESBuild to transform them on a per-file basis and ESBuild behaves wrong currently. See evanw/esbuild#1525 for more info. With TypeScript 4.5 this will all get easier by turning on |
@aloker What happens if you remove |
TS 4.5 is out with the new |
That option has been included in esbuild 0.14: https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#0140 Folks are focused on getting Vite 2.7 out-the-door, so I don't think it will upgrade the esbuild version. We'll probably have to wait awhile until Vite 2.8 is released. We're also looking at removing esbuild from some or all of the adapters (e.g. #2580 or #2931) |
I've sent a PR to upgrade to TypeScript 4.5: #3809 @dummdidumm I'm not quite sure how to leverage |
I believe this should have been fixed by #3064 |
Describe the bug
When value imports and type imports are mixed in a typescript file, the app will crash in the browser saying
import not found: NameOfTheImportedType
or that the imported file does not export "NameOfTheImportedType" (depends on the browser).This does not happen in .svelte files, only in .ts files.
What's new in Svelte: October 2021 mentions that "TypeScript users no longer have to strictly separate type imports and value imports when using Svelte version 3.39 or higher and svelte-preprocess version 4.9.5 or higher.", though I'm not sure if this is only related to .svelte files.
Reproduction
You should see:
Firefox:
Chrome:
Now go to src/lib/timeStore.ts (https://github.com/aloker/sveltekit-import-issue/blob/5749cbd79b725c550477924e399942bbfb1ade64/src/lib/timeStore.ts#L1-L6)
Use separate imports for the value and the type, ie
The page now works again.
Logs
System Info
Severity
annoyance
Additional Information
I couldn't find the related issue mentioned in the blog post. This might be a regression or a duplicate, I don't know. It might also rather belong to Svelte or vite.
The text was updated successfully, but these errors were encountered: