Last active
January 21, 2024 15:28
-
-
Save antfu/8530c4eaea9757d48be0add57e1ebb47 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