【发布时间】:2019-01-12 16:43:55
【问题描述】:
我正在将一些流代码转换为 ts,但不确定如何在 TS 中执行与此流代码等效的操作:
declare function $nullableAwait<T>(p: Promise<T> | T): T | null;
export function genAllNull<T: Iterable<mixed>>(...promises: T): Promise<$TupleMap<T, typeof $nullableAwait>> {
return Promise.all([].map.call(promises, genNull));
}
具体来说,我在 TS 中找不到任何相当于流中 $TupleMap 的东西,它允许我将类型数组从一种类型映射到另一种类型
【问题讨论】:
-
这是很好的代码 :-)
标签: javascript typescript flowtype