piecioshka / test-flowtype-vs-typescript

:ledger: Test project, which shows major differences between: FlowType and TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test-flowtype-vs-typescript

๐Ÿ“’ Test project, which shows major differences between: FlowType and TypeScript

Why?

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.

Source

  1. FlowType source file.

    /* @flow */
    
    'use strict';
    
    function Person(name: string) {
        this.name = name;
    }
    
    module.exports = Person;
  2. TypeScript source file

    'use strict';
    
    class Person {
        private name: string;
    
        constructor(name: string) {
            this.name = name;
        }
    }
    
    export default Person;
  3. 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? ๐Ÿ˜ฑ

How to run?

npm run build   # build basic scaffold
npm test        # trigger unit tests!

Conclusions

FlowType was created to keep proper type during runtime (life application)

TypeScript was created to keep proper type during translation process.

License

The MIT License @ 2016

About

:ledger: Test project, which shows major differences between: FlowType and TypeScript


Languages

Language:JavaScript 83.0%Language:Shell 9.7%Language:TypeScript 7.3%