Search code examples
ecmascript-6graphql-jses6-module-loader

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'; . Would anybody explain how is this kind of export possible (i mean with that type right there). is this somehow replacing default namespace?

they are everywhere in the codebase but here's one example: https://github.com/graphql/graphql-js/blob/master/src/index.js#L35


Solution

  • That syntax is specific to 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 so they can be shared across different modules.

    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. When the code is transpiled, the type definitions are stripped out.