简体   繁体   English

graphql-js是用Vanilla JavaScript编写的吗?

[英]Is graphql-js written in Vanilla JavaScript?

I started to learn graphql-js source code, but found it is difficult to determine whether the source code is written in vanilla js or typescript ? 我开始学习graphql-js源代码,但是发现很难确定源代码是用vanilla js还是typescript编写的?

For example, the main entry file src/graphql.js has the following code: 例如,主条目文件src/graphql.js具有以下代码:

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

I don't think the import type is standard js syntax. 我认为导入类型不是标准的js语法。 Can anyone please help explain what it is for? 谁能帮忙解释一下它的用途吗?

Also, the following code looks like TypeScript to me, but the file extension is js , not ts : 另外,以下代码对我来说就像TypeScript ,但是文件扩展名是js ,而不是ts

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

After asking the question, I did some research. 问了问题之后,我做了一些研究。 Apparently graphql-js uses the Flow Type , which is similar to TypeScript . 显然graphql-js使用Flow Type ,它与TypeScript相似。 James Kyles from Babel and Flow team explained the difference between Flow Type and TypeScript very well here Babel and Flow团队的James Kyles 在这里很好地解释了Flow TypeTypeScript之间的区别

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

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