【问题标题】:Is graphql-js written in Vanilla JavaScript?graphql-js 是用 Vanilla JavaScript 编写的吗?
【发布时间】:2017-09-01 03:51:48
【问题描述】:

我开始学习graphql-js源代码,但发现很难确定源代码是用vanilla js还是typescript写的?

例如主入口文件src/graphql.js有如下代码:

import type { GraphQLSchema } from './type/schema';
import type { ExecutionResult } from './execution/execute';

我认为导入类型不是标准的js 语法。谁能帮忙解释一下它是干什么用的?

此外,以下代码在我看来类似于 TypeScript,但文件扩展名是 js,而不是 ts

function graphql( 
   schema: GraphQLSchema,
   requestString: string,
   rootValue?: mixed,
   contextValue?: mixed,
   variableValues?: ?{[key: string]: mixed},
   operationName?: ?string):: Promise<ExecutionResult> {}

【问题讨论】:

    标签: javascript graphql-js


    【解决方案1】:

    问完这个问题后,我做了一些研究。显然graphql-js 使用Flow Type,类似于TypeScript。 Babel and Flow 团队的 James Kyles 很好地解释了 Flow TypeTypeScript 之间的区别 here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-21
      • 2019-05-01
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多