在typescript中使用/不使用typeof的区别



带/不带typeof前接口有什么区别?

它会改变行为吗?我找不到这方面的医生。

interface Props {
children: React.ReactNode;
}
type Item = React.FC<Props>;
type Component = React.FC & {
Item: typeof Item;
}
interface Props {
children: React.ReactNode;
}
type Item = React.FC<Props>;
type Component = React.FC & {
Item: Item;
}

第一个没有意义,因为typeof只能应用于值,而不能应用于类型。

最新更新