使用 es6-shim Promise.all() 时打字稿输入错误

typescript typings error when using es6-shim Promise.all()

问题
typescript 编译器似乎错误地为 Promise.all() 发出类型错误。

特别是,似乎是:

我查看了 es6-shim 中 Promise 的类型,但它们对我来说似乎是正确的。特别是,似乎这是被误解的行:

interface PromiseConstructor {
    all<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T[]>;
}

也许决定输入:Promise<PromiseLike<T>[]>
而不是 Promise 返回一个(非 Promise)值数组。

重现
OSX:埃尔卡皮坦 10.11.6 节点:v4.4.7
打字稿:1.8.10
打字:1.3.2

我设置了一个最小的例子,通过清除我的打字目录,运行:

typings install dt~es6-shim --save --global

然后我创建了一个测试文件,t.ts:

/// <reference path="typings/globals/es6-shim/index.d.ts" />
export function seedTestDatabase() : Promise<boolean[]> {
    type BP = Promise<boolean>
    var promises: BP[] = []
    var bp: BP = Promise.resolve(true)
    promises.push(bp)
    promises.push(Promise.resolve(true))
    var p = Promise.all(promises)
    return p
}

我编译了这个:

tsc --module commonjs t.ts

产生错误:

t.ts(9,12): error TS2322: Type 'Promise<Promise<boolean>[]>' is not assignable to type 'Promise<boolean[]>'.  
Type 'Promise<boolean>[]' is not assignable to type 'boolean[]'.  
Type 'Promise<boolean>' is not assignable to type 'boolean'.  

注意:代码 returns 一个 Promise 解析为值数组,正如预期的那样。

您使用的是哪个版本的 TS?

似乎是那个错误:https://github.com/Microsoft/TypeScript/issues/10143

已在 TS 2.0 beta 中修复。