Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

thecotne/state-of-js-type-systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

State Of JavaScript Type Systems

There are two major players in this field one is Flow written in ocaml by facebook and second is TypeScript written in TypeScript by microsoft.

Besides those there is new kid in the neighborhood called hegel written in JavaScript (with Flow and hegel) by ukrainian developer Artem Kobzar. hegel is not ready for prime time but it has much better design decisions and goals around type system then TypeScript and is written in JavaScript opposite to facebook's decision to use ocaml for JavaScript type system which greatly limits contributions from community.

This Repo is for comparing those three and tracking progress.

Type system itself

In this section we compare features and how well they are implemented.

  • note 01: no IDE support bullcrap in this section.
  • note 02: ??? links are used instead of abbr tags since those are not supported by github in readme.
CriteriaTypeScriptFlowHegel
Type safe try/catch/throwNo, #13219No, #2470Yes
ImmutabilityUnusable, #13347YesYes
Type inferenceSometimes, ???Mostly, ???Yes, ???
Enforce use of function return valueNoNo, #3914Yes
Prevent implicit type conversionSometimes, ???Sometimes, ???Yes, ???
Correctly balanced nominal and structural typingNo, ???YesYes
Library of type definitionsGood, DefinitelyTypedThere is something, flow-typedSame as TypeScript
Ability to enforce no extra propsSometimes, but it's hackyYes By DefaultYes By Default
Attempt to prevent runtime TypeErrorsNo non-goalMostly, it's design goalMostly, it's design goal
Type guardsUnusable, ???No, ???No
Assertion functionsUnusable, ???No, #112, ???No
Conditional typesYesNo, #6055, ???No

glossary

Term Meaning
Yes By Default It is implemented, it works and is turned on by default
Yes It is implemented and it works (it may or may not be turned on by default)
Mostly It is implemented and mostly covers use cases
Sometimes It has poor implementation that sometimes works and sometimes does not
Unusable It has so poor implementation that it rarely makes any difference
No It is not implemented
No non-goal It is not implemented and it will not be implemented in future

Who Uses What?

In this section we compare how popular each solution is amongs most impactful JavaScript projects.

Project Choice Proof
babel Flow 1
React Flow 1
Redux v1, v2 and v3 Flow 1 2 3
Redux v4 TypeScript 1
Vue.js v2 Flow 1
Angular v2+ TypeScript 1
date-fns both 1 2
meteor TypeScript but very few ts files 1
NEXT.js TypeScript but very few ts files 1
Gatsby v1 Flow 1
Gatsby v2 TypeScript but very few ts files 1
Rollup TypeScript but very few ts files 1
ember.js v3 TypeScript but very few ts files 1
Aurelia TypeScript but no ts files?! 1
Yarn v1 Flow 1
Yarn v2 (berry) TypeScript 1
NestJS TypeScript 1
AdonisJS TypeScript 1
Relay Flow 1

Many JavaScript projects are not using any type checking tool at all and many who use TypeScript don't go all in on it and have only about 1/4 of files converted to TypeScript

Also Flow seems to be loosing to TypeScript since some projects which started with flow did switch to TypeScript (like Redux, Gatsby and Yarn)

Contribution

feel free to open issue or pull request to point out any mistake (like missing punctuation or typo) or mission/inaccurate information.

About

State Of JavaScript Type Systems

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published