我想接受一个组件作为道具。
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
}
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)
我认为 typedef 可能应该是:
Error: Type 'typeof AComponent__SvelteComponent_' is missing the following properties from type
'SvelteComponentTyped<{ record: MyType; }>': $set, $on, …
Run Code Online (Sandbox Code Playgroud)