📅  最后修改于: 2021-01-11 13:00:39             🧑  作者: Mango
Facebook开发了Flow,这是一个JavaScript静态类型检查器,位于我们现有的JS代码之上。它是基于流的键入工具,而不是编程语言。为了提高我们的生产力,它做了很多工作。它使我们的程序更快,更智能,更自信,并且规模更大。
Flow使用静态类型注释检查代码是否存在错误。类型注释使我们能够告诉Flow我们希望代码如何工作,并且Flow将确保它以相同的方式工作。该流程是逐步可接受的。可以轻松地从我们的代码库中添加和删除它,而不会破坏任何内容。当我们只想对项目的一部分启用类型检查时,这很有用。
TypeScript是一种开源的纯面向对象编程语言。它是JavaScript的强类型超集,可编译为纯JavaScript。 TypeScript由Microsoft根据Apache 2许可开发和维护。它不是直接在浏览器上运行。它需要编译器才能在JavaScript文件中进行编译和生成。 TypeScript源文件的扩展名为“ .ts”。
Anders Hejlsberg开发了TypeScript。它于2012年10月1日首次向公众推出。经过Microsoft两年的内部开发,TypeScript 0.9的新版本于2013年发布。 TypeScript的当前版本是TypeScript 3.4.5 ,该版本于2019年4月24日发布。
从下表我们可以了解TypeScript和Flow之间的主要区别。
TypeScript | Flow | |
---|---|---|
Introduction | It is a typed superset of the JavaScript language. It is open-source and free programming language introduced by Microsoft. | It is a flow-based typing tool, not a programming language. It is a JavaScript static type checker that lives on top of our existing JS code. Flow is built to enable fast and precise code analysis. |
Design Goal | It is used to identify errors in programs through a balance between correctness and productivity. | It is used to enforce the type soundness/safety. |
Use Case (popular frameworks integration) | It becomes a better choice when we are working on Angular 2 or higher versions. | If we are working on React, Flow becomes a better choice as it is easily integrated with babel and the already present infrastructure. |
Benefits | The key benefits are:
|
The key benefits are:
|
Features | The main features of Typescript are:
|
The main features of Flow are:
|
Services | Along with the provision of static typing, it provides us with great language services and appropriate tooling that includes code refactoring, navigation, and auto-completion. | Along with the provision of static typing, Flow provides us a wide range of inter-procedural analysis and develops an in-depth understanding of our code. |
Advantages | The advantages of TypeScript are:
|
The advantages of Flow are:
|
Disadvantages | The disadvantages of TypeScript are:
|
The disadvantages of Flow are:
|
Utility size | 42.4 MB | 68.4 MB |