Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/niieani/typescript-vs-flowtype

Differences between Flowtype and TypeScript -- syntax and usability
https://github.com/niieani/typescript-vs-flowtype

comparison documentation flow flowtype hacktoberfest javascript-tools reference typescript typing

Last synced: 5 days ago
JSON representation

Differences between Flowtype and TypeScript -- syntax and usability

Awesome Lists containing this project

README

        

# TypeScript vs Flow

Both TypeScript and Flow are very similar products and they share most of their syntax with some important differences.
In this document I've tried to compile the list of differences and similarities between Flowtype and TypeScript -- specifically the syntax, usage and usability.

## Disclaimer

*This document might be incomplete and/or contain mistakes and was last updated to describe **TypeScript 3.7.0** and **Flow 0.101**.*

*I'm maintaining it in my spare time, so if you find mistakes, or learn about latest additions to either project, please help keep this repo up-to-date by contributing and [editing this page](https://github.com/niieani/typescript-vs-flowtype/edit/master/README.md).*

*Thanks!*

# Differences in usage and usability

Some of these differences are subjective (e.g. error readability), and I'd love to make this as scientific as possible — so please [contribute](https://github.com/niieani/typescript-vs-flowtype/edit/master/README.md) to make it better. :)

| | TypeScript | Flow |
|---|------------------|--------|
| Leading Design Goal / North Star | identify errors in programs through [a balance between correctness and productivity](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals) | enforce type soundness / safety |
| IDE integrations | top-notch: language server, built-in refactorings, type and typedoc information on hover, snappy go-to-definition | language server is a work in progress, some IDEs use the CLI and require saving the file to run the type-check, refactorings in alpha, only type information on hover, sketchy go-to-definition |
| type-checking speed (excluding transpilation) | [benchmarks needed](https://github.com/niieani/typescript-vs-flowtype/edit/master/README.md) | [benchmarks needed](https://github.com/niieani/typescript-vs-flowtype/edit/master/README.md), [in-depth description numberOfFiles · O( (LoCperFile + SizeOfTypesOfExports) ^ k ) ](https://youtu.be/WgvAPzOmiP0?t=616) |
| autocomplete |


  • both during declaration and usage

  • feels instantaneous

  • feels reliable

|

  • [only for usage](https://github.com/facebook/flow/issues/3074)

  • feels sluggish (often a second or more of delay)

  • feels unreliable (sometimes does not show up at all)

|
| expressiveness | great (since TS @ 2.1) | great |
| type safety | very good (7 / 10) | great (8 / 10) |
| specifying generic parameters during call-time (`f(x)`) | yes [e.g.](http://www.typescriptlang.org/play/#src=function%20someFactory%3CT%3E()%20%7B%0D%0A%20%20return%20class%20%7B%0D%0A%20%20%20%20method(someParam%20%3A%20T)%20%7B%0D%0A%20%20%20%20%20%20%0D%0A%20%20%20%20%7D%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2F%20how%20to%20invoke%20this%20factory%20with%20a%20defined%20%3CT%3E%3F%0D%0A%0D%0Aconst%20SomeClass%20%3D%20someFactory%3C%7B%20whatever%3A%20string%20%7D%3E()%0D%0Aconst%20someInstance%20%3D%20new%20SomeClass()%0D%0AsomeInstance.method('will-error-here')%0D%0A) | yes (since Flow 0.72) |
| specifying generic parameters for type definitions | yes | yes |
| typings for public libraries | plenty of well maintained typings | a handful of mostly incomplete typings |
| unique features |

  • autocomplete for object construction

  • declarable `this` in functions (typing `someFunction.bind()`)

  • large library of typings

  • more flexible [type mapping via iteration](https://github.com/Microsoft/TypeScript/pull/12114)

  • namespacing

|

  • variance

  • existential types `*` (deprecated since 0.72)

  • testing potential code-paths when types not declared for maximum inference

  • `$Diff` type

|
| type spread operator | no ([planned](https://github.com/microsoft/TypeScript/issues/10727)) | [shipped](https://github.com/facebook/flow/commit/ad443dc92879ae21705d4c61b942ba2f8ad61e4d) >=0.42 |
| support for nullish coalescing proposal | [shipped](https://github.com/microsoft/TypeScript/pull/32883) > 3.7beta | yes |
| support for decorators proposal | yes, legacy proposal | only parsing of legacy proposal, no type-checking |
| support for extending built-in types | yes | no |
| userland plugins | [basic](https://github.com/Microsoft/TypeScript/issues/6508), not effecting emitting yet (planned) | no |
| programmatic hooking | architecture prepared, work in progress | work in progress |
| documentation and resources |

  • very good docs

  • many books

  • videos

  • e-learning resources

|