"types first" Flow 架构是什么?
What is the "types first" Flow architecture?
Flow 团队的 blog post 描述了一个名为 "types-first" 的 "re-architecture" Flow。据我所知,唯一的描述是来自博客 post:
的引用
"...it exploits full type annotations at file boundaries to perform better (more parallelizable and less redundant) separate compilation."
有没有关于此的更多详细信息?具体来说,我想知道这些完整的注释是什么:对源代码和声明文件的新限制是什么?
例如,这允许吗?
import { func } from "./other-module";
export const myNumber = func(num1, num2);
在 TypeScript 中这是有问题的,因为 myNumber
的类型在不知道 func
的类型的情况下是不可能解析的。 "types-first" Flow 的重新架构是否需要用户编写:
import { func } from "./other-module";
export const myNumber: number = func(num1, num2);
这只是我的一个具体问题。我正在寻找的是更多信息和一份 link 文档,该文档解释了重新架构的所有已知影响。
这听起来真的很华而不实,也许它在幕后。但实际上这很简单。在你的代码片段中,你是绝对正确的,它几乎就是这个意思。
You must have an explicitly defined type before you export
虽然不一定是在导出之前。以下也适用。
const TestComponent = (): React.Node => {};
export default TestComponent;
它增加了一点开销,但好处是:
- 性能改进,因为流不需要扫描所有依赖项就可以为您提供健全性检查
- 更可靠的代码,因为流在模块边界内运行,所以您不会遇到由深度嵌套的依赖项引起的流错误。
他们还发布了一个新博客 post,进一步介绍了类型,因为现在正式发布了类型。
https://medium.com/flow-type/types-first-a-scalable-new-architecture-for-flow-3d8c7ba1d4eb
更新 类型优先架构现在是 documented。
Flow 团队的 blog post 描述了一个名为 "types-first" 的 "re-architecture" Flow。据我所知,唯一的描述是来自博客 post:
的引用"...it exploits full type annotations at file boundaries to perform better (more parallelizable and less redundant) separate compilation."
有没有关于此的更多详细信息?具体来说,我想知道这些完整的注释是什么:对源代码和声明文件的新限制是什么?
例如,这允许吗?
import { func } from "./other-module";
export const myNumber = func(num1, num2);
在 TypeScript 中这是有问题的,因为 myNumber
的类型在不知道 func
的类型的情况下是不可能解析的。 "types-first" Flow 的重新架构是否需要用户编写:
import { func } from "./other-module";
export const myNumber: number = func(num1, num2);
这只是我的一个具体问题。我正在寻找的是更多信息和一份 link 文档,该文档解释了重新架构的所有已知影响。
这听起来真的很华而不实,也许它在幕后。但实际上这很简单。在你的代码片段中,你是绝对正确的,它几乎就是这个意思。
You must have an explicitly defined type before you export
虽然不一定是在导出之前。以下也适用。
const TestComponent = (): React.Node => {};
export default TestComponent;
它增加了一点开销,但好处是:
- 性能改进,因为流不需要扫描所有依赖项就可以为您提供健全性检查
- 更可靠的代码,因为流在模块边界内运行,所以您不会遇到由深度嵌套的依赖项引起的流错误。
他们还发布了一个新博客 post,进一步介绍了类型,因为现在正式发布了类型。 https://medium.com/flow-type/types-first-a-scalable-new-architecture-for-flow-3d8c7ba1d4eb
更新 类型优先架构现在是 documented。