Don't even know if this is possible, so here goes nothing...
type CustomProps = {
id: string;
defaultValue: number;
}
function MyComponent(props: CustomProps){
return <div>my custom fc</div>;
}
type Desired = {
shape: React.ComponentType<any>
}
const x: Desired = {
shape: MyComponent,
// the issue is, to transform x on-the-fly
// AFTER shape is declared
// so it can extend the type of props MyComponent can receive
// basically x becomes `Desired` & `CustomProps`
}
I know I can declare a type param for Desired
, infer props, and that would make it work, but... it's not what i'm looking for.
This even possible?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…