You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test.js:12
12: var nullableStrings = await Promise.all(array.map((a) => genString(a)));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call of method `all`
12: var nullableStrings = await Promise.all(array.map((a) => genString(a)));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Promise. This type is incompatible with
446: declare function $await<T>(p: Promise<T> | T): T;
^^^^^^^^^^^^^^ union: type application of identifier `Promise` | type parameter `T` of await. See: /private/tmp/flow/flowlib_12ad72f7/core.js:446
Found 1 error
Which was tricky to debug, I couldn't quite figure out what I was doing wrong. Changing:
-async function useArray(): Promise<Array<string>> {+async function useArray(): Promise<Array<?string>> {
or
- return nullableStrings.filter((s) => s != null);+ var strings = [];+ nullableStrings.forEach((s) => {+ if (s != null) {+ strings.push(s);+ }+ });+ return strings;
leads to:
No errors!
Which makes me think the problem was not with line 12 in the original source, but line 13, where I attempted (incorrectly, as per #1026) to convert the Array<?string> to an Array<string> with .filter((s) => s != null).
I'm running:
$ flow version
Flow, a static type checker for JavaScript, version 0.20.1
The text was updated successfully, but these errors were encountered:
I ran into a tricky error earlier today, reduced it to this repro case:
The flow error is:
Which was tricky to debug, I couldn't quite figure out what I was doing wrong. Changing:
or
leads to:
Which makes me think the problem was not with line 12 in the original source, but line 13, where I attempted (incorrectly, as per #1026) to convert the
Array<?string>
to anArray<string>
with.filter((s) => s != null)
.I'm running:
The text was updated successfully, but these errors were encountered: