Closed
Description
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.
Metadata
Assignees
Labels
No labels
Activity