📒 Test project, which shows major differences between: FlowType and TypeScript
A couple of days ago, I read comments in a blog post http://michalzalecki.com/typescript-vs-flow/ and decided to run tests to show the major differences between FlowType and TypeScript.
-
FlowType source file.
/* @flow */ 'use strict'; function Person(name: string) { this.name = name; } module.exports = Person;
-
TypeScript source file
'use strict'; class Person { private name: string; constructor(name: string) { this.name = name; } } export default Person;
-
After compilation when I run the line
new Person(123);
-
in the FlowType strategy I got an error ⛔
Hello BDD! Runtime error occur! 😎
-
following the TypeScript way nothing happens ...
Eh... no runtime errors? Why? 😱
npm run build # build basic scaffold
npm test # trigger unit tests!
FlowType was created to keep proper type during runtime (life application)
TypeScript was created to keep proper type during translation process.
The MIT License @ 2016