I am trying to pass a component as a prop.
import AComponent from './AComponent.svelte';
type MyType = {
[key: string]: any; // just an example
}
type AcceptComponentProp<T> = {
component: SvelteComponentTyped<{ record: T }>;
}
const componentPropObject: AcceptComponentProp<MyType> = {
component: AComponent // getting an 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 thought changing the typedef might help:
type AcceptComponentProp<T> = {
component: typeof SvelteComponentTyped<{ record: T }>;
}
But that led to even more strange errors.
It's crucial for this typing to be clear and explicit since it will be part of the interface exposed to users.