Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shift from Flow to TypeScript #306

Closed
tiffon opened this issue Jan 3, 2019 · 1 comment
Closed

Shift from Flow to TypeScript #306

tiffon opened this issue Jan 3, 2019 · 1 comment
Assignees

Comments

@tiffon
Copy link
Member

tiffon commented Jan 3, 2019

In the Flow vs TypeScript comparison, TypeScript has emerged as more robust and popular than Flow.

From the State of JavaScript 2018 Survey:

Language Would like to learn Would use again Total Source
Flow 24.2% 10.2% 34.6% link
TypeScript 33.7% 46.7% 80.4% link

DefinitelyTyped has more type definitions than flow-typed.

There are also many bugs or shortcomings in Flow which do not appear to be issues in TypeScript. For example, in Flow:

class Thing<T, U> {
  static newThing<V>(factory: () => V) {
    const thing: Thing<string, V> = new Thing(factory);
    return thing;
  }

  items: T[];
  factory: () => U;
  constructor(factory: () => U) {
    this.factory = factory;
    this.items = [];
  }
}

const fn: () => number = () => 0;
const t: Thing<string, number> = Thing.newThing<number>(fn);
const t2: Thing<string, number> = Thing.newThing<number>(() => 0);

Results in the following error:

16: const t: Thing<string, number> = Thing.newThing<number>(fn);
                                     ^ Cannot assign `Thing.newThing<...>(...)` to `t` because `V` [1] is incompatible with number [2] in type argument `U` [3].
    References:
    3:     const thing: Thing<string, V> = new Thing(factory);
                                      ^ [1]
    16: const t: Thing<string, number> = Thing.newThing<number>(fn);
                               ^ [2]
    1: class Thing<T, U> {
                      ^ [3]

17: const t2: Thing<string, number> = Thing.newThing<number>(() => 0);
                                      ^ Cannot assign `Thing.newThing<...>(...)` to `t2` because `V` [1] is incompatible with number [2] in type argument `U` [3].
    References:
    3:     const thing: Thing<string, V> = new Thing(factory);
                                      ^ [1]
    17: const t2: Thing<string, number> = Thing.newThing<number>(() => 0);
                                ^ [2]
    1: class Thing<T, U> {
                      ^ [3]

But, this works without issue in TypeScript.

@tiffon tiffon self-assigned this Jan 3, 2019
@tiffon tiffon changed the title Shift from Flow to Typescript Shift from Flow to TypeScript Mar 20, 2019
@tiffon
Copy link
Member Author

tiffon commented Mar 27, 2019

Fixed by #359.

@tiffon tiffon closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant