graphql-js 导出类型如何工作?

graphql-js how does export type work?

我一直在研究代码库,这种类型的导出让我感到困惑 export type { GraphQLArgs } from './graphql';。谁能解释一下这种导出是如何实现的(我的意思是 type 就在那里)。这是否以某种方式取代了 default 命名空间?

它们在代码库中无处不在,但这里有一个例子: https://github.com/graphql/graphql-js/blob/master/src/index.js#L35

该语法特定于 Flow, not ES6. Flow uses static type annotations (or just "types") to help you catch errors more easily. Normally, these types are defined in the module where they are used, but Flow also allows you to import and export types,因此它们可以在不同模块之间共享。

Flow 类型本身不会影响代码的逻辑——它们只存在于 type-check 您的代码中,这通常是通过 command-line 完成的。当代码被转译时,类型定义被删除。