Imagine you import a React.Component (let's call it Foo) from any library (e.g. from node_modules). Now you want to extract the type of a prop (let's call it complexProp) from Foo, so you can use it elsewhere.
Example
Foo.tsx:
interface FooProps <P /*some generic stuff here*/> {
complexProp: /*some super weird type you can not simply copy*/;
}
export class Foo extends React.Component<FooProps> {
//...
public render(){
//...
lookAtComplexProp(this.props.complexProp)
//...
}
}
function lookAtComplexProp(complexProp: /* I need the type of Foo.props.complexProp here*/) {
//...
}
- Is this somehow possible?
- Exspecially, is this possible without
knowing anything about the code behind
Foo? In other words, is a syntax liketype complexPropType = Foo.complexProp.getType();possible?