在 CommonJS 中导出流类型?

Exporting Flow type in CommonJS?

是否可以像 ES6 like type imports/exports 一样在 CommonJS 世界中导出和导入 Flow 类型定义?

Flow 没有 CommonJS 风格的 require,但 Flow 的 import type/export type 语法可以与 CommonJS require 调用一起使用。

虽然语法看起来相似,但 import typeexport type 并不是实际的 JavaScript import/export 语句。在您的代码在当前浏览器中可以 运行 之前,必须将它们从您的代码中删除。例如,如果你使用 Babel 来编译你的代码,你可以使用 transform-flow-strip-types 插件来剥离 Flow 类型并输入 imports/exports.