language-tools: š BUG: Svelte components using .d.ts declarations with SvelteComponentTyped are not supported
Describe the Bug
SvelteComponentTyped
ās constructor expect a target
attribute to be passed. I am unfortunately not super knowledgeable in Svelteās internals to know what itās used for, but one thing is sure: We donāt pass it in Astro files.
Looking at Svelte2tsx tests, it seems like passing it a dummy value is okay, but the problem is that unlike Svelte, we donāt know if a components needs it or not (and passing it to all components would lead to errors for other frameworks).
A possible solution would be to patch the definition of SvelteComponentTyped
when we load the snapshot for Svelteās dev.d.ts
, but I wouldnāt be surprised if that brings in more issues š¤
Workaround
Importing the component directly works, provided that itās exported. ex: import Theme from 'carbon-components-svelte/src/Theme/Theme.svelte';
Steps to Reproduce
- Import a component from a Svelte library with typings, ex:
import {Ā Theme } from "carbon-components-svelte"
- Use it in the template
- Error! Says
target
is required even though that props doesnāt exist
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 15 (3 by maintainers)
That package is very weirdly packaged, it only has a single export using a non-standard export name and it declares its types using a fake module
https://github.com/jacobmischka/svelte-flatpickr/blob/master/package.json#L32-L36
I donāt really know how we would support that without implementing Svelteās module resolution I assume. If the package just exposed the files normally, you could just import the Svelte components.