-
-
Save hunghg255/195281aa2aeb53cb745d2fad31e7a566 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type GetComponentProps<T> = T extends React.ComponentType<infer P> | |
? P | |
: T extends (props: any) => any | |
? Parameters<T> | |
: never; | |
class ClassComponent extends React.Component<{ a: number }> { | |
render() { | |
return <div />; | |
} | |
} | |
const FunctionalComponent = (props: { v: string }) => { | |
return <div />; | |
}; | |
type a = GetComponentProps<typeof ClassComponent>; | |
type b = GetComponentProps<typeof FunctionalComponent>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment