[英]React & TypeScript - what's the difference between `React.Component` and `typeof React.Component`
[英]difference between with/without typeof in typescript
接口前有/沒有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
只能應用於值,不能應用於類型。
TypeScript 添加了一個 typeof 運算符,您可以在類型上下文中使用它來引用變量或屬性的類型
了解有關 Typeof 類型運算符的更多信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.