简体   繁体   English

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

[英]graphql-js how does export type work?

i've been looking into the codebase and this type of export confuses me export type { GraphQLArgs } from './graphql'; 我一直在研究代码库,这种类型的导出使我对export type { GraphQLArgs } from './graphql'; . Would anybody explain how is this kind of export possible (i mean with that type right there). 会有人解释这是怎么样的出口可能的(我的意思是与该type在那里)。 is this somehow replacing default namespace? 这是以某种方式替换default名称空间吗?

they are everywhere in the codebase but here's one example: https://github.com/graphql/graphql-js/blob/master/src/index.js#L35 它们在代码库中无处不在,但这是一个示例: https : //github.com/graphql/graphql-js/blob/master/src/index.js#L35

That syntax is specific to Flow , not ES6. 该语法特定于Flow而不是ES6。 Flow uses static type annotations (or just "types") to help you catch errors more easily. Flow使用静态类型注释(或仅使用“类型”)来帮助您更轻松地捕获错误。 Normally, these types are defined in the module where they are used, but Flow also allows you to import and export types so they can be shared across different modules. 通常,这些类型在使用它们的模块中定义,但是Flow还允许您导入和导出类型,以便可以在不同模块之间共享它们。

The Flow types themselves don't impact your code's logic -- they only exist to type-check your code, which is typically done via command-line. Flow类型本身不会影响您代码的逻辑-它们仅用于类型检查您的代码,这通常是通过命令行完成的。 When the code is transpiled, the type definitions are stripped out. 编译代码时,将删除类型定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM