have a large and/or distributed team » People move from/to your team often » Your application have complex data structures and a lot of client-side logic » You plan to (often) refactor your code
Written in OCaml » Only a Type Checker » Requires Babel or a similar tool to remove its type annotations » Needs an annotation in the files to be checked ( // @flow )
» Written in Typescript » A new language, superset of Javascript (es6/7/8+) » Has its own compiler to transpile and remove type annotations » Files extension must be .ts (.tsx for react)
could be undefined const sum = (a: number, b?: number): number | void => { if (b) { return a + b } } const summed: number | void = sum(2, 3) if (summed) { // safely use summed as a number }
{ age: number } class Dog { name: string } const animal: Animal = new Dog() // Error, type doesn't match const animal: Animal = new Horse() // Valid, Horse extends Animal
{ age: number } class Dog { name: string age: number barf() {} } const animal: Animal = new Dog() // Valid, the classes structure match const animal: Animal = new Horse() // Valid, Horse extends Animal