Flow libdefs 中$Export变量的含义是什么?



我正在使用流类型。

我在某些 libdefs 中遇到了变量$Export。我不知道它是什么以及它在哪里记录。

对我来说,它似乎类似于实用程序类型,但$Export的问题没有在那里描述。有谁能解释它以及它来自哪里?

declare module "@material-ui/core/AppBar/AppBar" {
  import type {ComponentType, Node} from "react";
  declare type Color = "inherit" | "primary" | "secondary" | "default";
  declare type Position = "fixed" | "absolute" | "sticky" | "static" | "relative";
  declare module.exports: ComponentType<{
    children?: Node,
    className?: string,
    classes?: Object,
    color?: Color,
    position?: Position
  }>;
}
declare module "@material-ui/core/AppBar" {
  declare module.exports: $Exports<"@material-ui/core/AppBar/AppBar">;
}

查看此 Github 线程,它们似乎是内部方法

定义似乎在这里:

https://github.com/facebook/flow/blob/master/src/typing/type_annotation.ml#L491

哪里有这个评论:

(*  $Exports<'M'> is the type of the exports of module 'M'

所以它基本上是一个模块加载器,用于所有意图和目的,直到 TODO 列表中的项目到达

 (** TODO: use `import typeof` instead when that lands **)

最新更新