从 React 组件中提取 props 类型
Extract props type from React component
我正在尝试了解如何(如果可能的话)从给定组件中提取道具类型。
const Component = (props: { color: string }) => <div {...props} />;
type ComponentProps = $ExtractArguments<typeof Component>[0] // pseudo-code
我在谷歌上找到了这个实用程序,但我不知道它是否有用...
type $Arguments<F> = $Call<<A: $ReadOnlyArray<mixed>>((...A) => mixed) => A, F>;
我正在尝试了解如何(如果可能的话)从给定组件中提取道具类型。
const Component = (props: { color: string }) => <div {...props} />;
type ComponentProps = $ExtractArguments<typeof Component>[0] // pseudo-code
我在谷歌上找到了这个实用程序,但我不知道它是否有用...
type $Arguments<F> = $Call<<A: $ReadOnlyArray<mixed>>((...A) => mixed) => A, F>;