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

问题描述 投票:2回答:1

我正在使用flow-typed。

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

对我而言,它似乎与Utility Types类似,但$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">;
}
javascript flowtype flow-typed
1个回答
2
投票

看看this Github thread,他们似乎是内部方法

定义似乎在这里:

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 **)
© www.soinside.com 2019 - 2024. All rights reserved.