I want to accept a component as a prop.
import AComponent from './AComponent.svelte';
type MyType = {
[key: string]: any; // just an example
}
type IWantToAcceptAComponent<T> = {
component: SvelteComponentTyped<{ record: T }>;
}
const componentPropObject: IWantToAcceptAComponent<MyType> = {
component: AComponent // error here
}
Error: Type 'typeof AComponent__SvelteComponent_' is missing the following properties from type
'SvelteComponentTyped<{ record: MyType; }>': $set, $on, $destroy, $$prop_def, and 5
more.ts(2740)
I figured it might be that the typedef should be:
type IWantToAcceptAComponent<T> = {
component: typeof SvelteComponentTyped<{ record: T }>;
}
But that causes even weirder errors.
It's fairly important that this typing is explicit, as it's supposed to be part of an exported interface for users.