My question is kinda to my previous one: ReactTS extend type by dynamic Component Props?
So lets say I've got the next lines:
type Base = {
baseProp: ...
}
type Extend = {
extendProp: ...
}
// use this if "as" undefined
type DefaultPropsToExtend = {
defaultToExtendProp: ...
}
declare const ExtendedComponent: React.FC<Extend>
declare const DefaultExtendedComponent: React.FC<DefaultPropsToExtend>
function Base<T = DefaultPropsToExtend>(props: BaseProps & { as: React.ComponentType<T> } & T): React.ReactElement {
const Wrapper = props.as
return <Wrapper />
}
So what I expect when I call the next lines are:
<Base /> // props can be => { baseProp, defaultToExtendProp }
What props actually I am seeing => { baseProp }
If I am doing the next then things working property, but this way I need to be explicit about the default "as" every time.
<Base as={DefaultToExtendComponent} /> // => { baseProp, defaultToExtendProp }