-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
TS doesn't understand mount()
return type
#14966
Comments
The TS's type ( |
@Bilge so as to try to clear things up: Svelte v5 components are no longer classes and instead they are functions. So your |
OK? But I need some way to type my local variable such that I know what it exports and what methods I can call on it. |
Don't type it explicitly. TypeScript will infer the type from the construction assignment. |
lol, no.
|
Yeah, that's because you don't have strict mode on. It's part of |
In Svelte 5, the instance type is
You also need to fix this |
You need to disable webpack's type checking, it does not know about the exact value of Svelte component exports: https://stackoverflow.com/questions/60278796/how-to-ignore-typescript-errors-when-compile-by-webpack-production-mode |
I'm now looking at migrating to svelte 5 and I'm experiencing this same issue. Although I also use webpack + fork-ts-checker-webpack-plugin so TS errors are reported back I also see the same errors are reported just doing |
Describe the bug
If I assign the result of
mount(Foo)
to a variable typedFoo
, TS gets confused and emits:Nevertheless,
svelte-check
finds no errors and my editor understands the return type ofmount(Foo)
isFoo
. It is only TS compilation via webpack that is problematic.Reproduction
Logs
Here are my
tsconfig.json
files.(This is
..
)Relevant portion of
webpack.config.js
.System Info
Severity
blocking all usage of svelte
The text was updated successfully, but these errors were encountered: