-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Cannot use records inside new generics="T extends { key: string }"
attribute
#2039
Comments
The record thing is a good catch, the Svelte parser thinks it's a mustache tag when it shouldn't. Mhm we may need to special-case this inside the parser, or add a change to the typescript preprocessor where it strips the generics attribute. The latter is now easily possible in Svelte 4, so that's probably the most promising route. |
What's the official status of the |
Hey, guys!✨ |
Got the same issue, what's the recommended way to use $$Generic now? |
Related to sveltejs/language-tools#2204 / sveltejs/language-tools#2039 The Svelte 5 version of #9486 and #9498
Related to sveltejs/language-tools#2204 / sveltejs/language-tools#2039 The Svelte 5 version of #9486 and #9498 --------- Co-authored-by: Rich Harris <[email protected]> Co-authored-by: Rich Harris <[email protected]>
This is fixed in the latest version of Svelte 4. Update to it and the error should go away. |
WOOOOOWWWWW✨✨✨✨✨ |
I still get an error when using: <script lang="ts" generics="T extends { id: string }">
</script> Error: |
I can also confirm that this: <script lang='ts' generics='T extends { foo: string }'>
</script> does not work for me.
|
These snippets work for me, please make sure that you're running the latest version of the VS Code extension / the svelte language server if you're not using VS Code / svelte-check |
I am running this version of the Svelte for VS Code extension: this seems to me to be the latest version, and I am still seeing these errors |
Could you provide a reproduction repository? |
sure: https://github.com/ollema/gh-lang-tools-2039-repro also added system/svelte/extension information in opening up this repo in VS Code and selecting the
or
|
is the reproduction working for you @dummdidumm? |
Svelte 4 has some fixes with regards to parsing the generics attribute. #2039
Yes, was able to reproduce it, thanks. Fix incoming. |
Describe the bug
Using the new generics notation introduced in #2020, you cannot use records the generics attribute because the
generics
attribute is parsed as an HTML string, not as TypeScript code.Reproduction
Gives the error:
Expected behaviour
This entire string is parsed as JS and not as a string with interpolation.
System Info
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
There is a workaround, but I don't think this is ideal.
The text was updated successfully, but these errors were encountered: