簡體   English   中英

typescript 中有/無 typeof 的區別

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM