-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
svelte-check/typescript detecting type mismatch where there shouldn't be one #8860
Comments
Gah, this is tricky. I think the problem is that TypeScript doesn't know whether or not the generic extends never, so it will not narrow the extends clause to any of the possibilities. We probably need to find some type hack to work around this. |
I am not a master of TypeScript generics; is there a way for me to put a constraint on the generic to tell TypeScript that it never extends |
Type check in Rider (IntelliJ) is complaining about
|
Narrowed this down to microsoft/TypeScript#54806, let's see what happens (I fear this is a TS limitation) |
That snippet should be working. JetBrain's Svelte plugin is unfortunately unusable at this moment and I would advise against using it; What you are experiencing is just one of many things that doesn't work. |
Ah I understand now. Yeah, maybe better to see what TypeScript can do about it, since that does seem like something they probably would want to fix as well. |
Interesting, been using that plugin over a year in my Svelte project (not Sveltekit) with not to much drama. |
Does that same snippet work within a |
Yes, it works in plain .ts file, only a problem inside |
Then that sounds like another case where the plugin doesn't quite work right - though I remember that they just announced to use the |
fixes #8860 This contains a small but unfortunately unavoidable breaking change: If you used `never` to type that the second parameter shouldn't be set (which the docs recommended for a short time), then you need to change that to `null`
Been using it myself at work for about 2 years on and off (have given up and used VSCode last 6 months), and I am sure on smaller projects you have a decent chance of not experiencing much issues, but dive into a larger project and you'll hit wall after wall:
If they can manage to use the svelte language server instead of their own it would help a lot, since without it they basically have to make their own from scratch. I'm not sure how they would do it, since JetBrain's language tools uses their own little programming language, but last WebStorm update they said Vue now uses Volar so maybe they figured it out (haven't tried Vue in a while, let alone with WebStorm). |
@dummdidumm Do you mind me asking why in the playground for the TypeScript issue (and in svelte source code for that matter), you use |
This blog post explains it quite nicely: https://www.zhenghao.io/posts/ts-never#how-to-check-for-never |
…function types (#8872) fixes #8860 This contains a small but unfortunately unavoidable breaking change: If you used `never` to type that the second parameter of `createEventDispatcher` shouldn't be set or that the action accepts no parameters (which the docs recommended for a short time), then you need to change that to `null` and `undefined` respectively
Describe the bug
svelte-check
/typescript detecting mismatch where there shouldn't be oneReproduction
Logs
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: