-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
🐛 BUG: Props are not inferred with a Svelte generic component #772
Comments
Might just be a question of updating the Thank you for submitting an issue! |
I just looked in the |
I dig up a little to understand how the integration is done. I have not tested but I think the issue comes from these lines in export default class extends __sveltets_2_createSvelte2TsxComponent( We can see that this is the case in the following Svelte tests: However, when the export default class Input__SvelteComponent_<const T extends readonly string[]> extends __SvelteComponentTyped__<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> { So I guess we are loosing the correct types because of the If I'm correct it seems I pick up the wrong repository again. The issue belongs to the |
Thank you for investigating! That replace is definitely brittle, I kinda wish we could remove it. Maybe in the future. Despite this issue being in code that's in the main repo, we typically keep issues about this here, so no worries! |
Describe the Bug
Before all, once again, I'm note sure if it is a compiler or a language-tools issue. I guess it is not the compiler since the app can be build without errors. Sorry if I picked up the wrong repository.
Context
Svelte supports the creation of generic components using Typescript. The syntax that was retained looks like:
However, it seems this API is still experimental and not yet documented on the Svelte website.
The issue
When importing a generic component in a Svelte file, everything works as expected: the props are correctly inferred and we can have auto-completion in VS Code.
When importing the same generic component in an Astro file, the app can be build (no errors, and the component is visible in the browser). However, the Props are not inferred and Typescript complains.
Example
With this component:
If I try to import it in a file with the
.astro
extension, I can't benefit from the intellisense.And Typescript gives me the following error:
My expectations
No errors from Typescript and the ability to use the intellisense to fill the props, like any component.
System info
Steps to Reproduce
I created a Stackblitz that can be downloaded and opened in VS Code (since the parser won't work otherwise). It contains three files in
src/components
:List.svelte
)SvelteTest.svelte
)AstroTest.svelte
)Here the steps to manually reproduce the error:
npm create astro@latest -- --template framework-svelte
(and install the Astro and Svelte extensions if needed)Yes
for everything (and keepStrict
for Typescript)src/components/List.svelte
that contains our generic component:src/components/SvelteTest.svelte
:src/components/AstroTest.astro
:class List<T extends boolean = false>
The text was updated successfully, but these errors were encountered: