Skip to content

Error inferring types of promise function #17873

Open
@ghost

Description

TypeScript Version: nightly (Version 2.5.0-dev.20170816)

Code

(based on DefinitelyTyped/types/bluebird/index.d.ts)

declare function props<K, V>(x: PromiseLike<Map<K, PromiseLike<V> | V>>): Promise<Map<K, V>>;
declare const input: Promise<Map<number, Promise<string>>>;
const out: Promise<Map<number, string>> = props(input);

Expected behavior:

No error.

Actual behavior:

src/a.ts(3,7): error TS2322: Type 'Promise<Map<number, Promise<string>>>' is not assignable to type 'Promise<Map<number, string>>'.
  Type 'Map<number, Promise<string>>' is not assignable to type 'Map<number, string>'.
    Type 'Promise<string>' is not assignable to type 'string'.

It works if I explicitly specify props<number, string>(input).
The error only reproduces with "lib": ["es6"].

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-repros

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions