FlowType 用于定义接口的语言是什么?

What is the language FlowType uses to define interfaces?

本文关键字:语言 是什么 接口 用于 定义 FlowType      更新时间:2023-09-26

FlowType接口文件是使用某种语言声明的。本页包含一些示例。我在哪里可以获得该语言的概述,或演示所有可用令牌/类型/功能的冗长界面文件的示例?

以下是快速概述:

declare module ModuleName {
  ...more declare statements
}
declare module "QuotedModuleName" {
  ...more declare statements
}
declare module ModuleWithDefaultExport {
  // declare class exports or declare function exports also works
  declare var exports: exportType;
}
declare class ClassName {
  propertyName: propertyType;
  methodName(arg1: argType): returnType;
}
declare function functionName(arg1: argType): returnType;
declare var varName: varType;
interface InterfaceName {
  propertyName: propertyType;
  methodName(arg1: argType): returnType;
}
type TypeName = someType;

流二进制文件附带了一些嵌入其中的库文件。这些库指定了一些非常基本的东西,比如核心JavaScript内置,DOM API,Node的API等。你可以在github上浏览这些库文件。

文档中的

快速参考页面很好地概述了所有语言功能。Flow GitHub 存储库中的 lib 目录包含 JavaScript 标准库、DOM、React 和 Node 的类型定义,这些都是很好的起点。

TypeScript 和 Flow 的语法之间存在很大程度的重叠,因此您喜欢的库的 DefinitelyTyped TypeScript 定义将为您提供一些可能只需稍作修改即可在 Flow 中工作的东西。对于初学者来说,两者之间最大的区别在于您如何配置和运行它们。

声明模块声明类 你在示例页面中看到的 在 TypeScript 中:你可以在官方网站上了解该语言。

基本上,Typescript 使用更面向的对象语法来编写你的 JavaScript 应用程序(最后,它会将你的代码编译为 javascript)。

关于如何使用 Flow 的示例,您可以找到 Flow 的参考,甚至可以在 Flow Github 存储库中找到示例。