Skip to content

Error inferring types of promise function #17873

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"].

Activity

  1. ghost added
    BugA bug in TypeScript
    on Aug 21, 2017
  2. rubiesonthesky commented on Mar 10, 2024

    @rubiesonthesky

    This is still giving error, here is repro for bot.

    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);

    Workbench Repro

  3. added
    Has ReproThis issue has compiler-backed repros: https://aka.ms/ts-repros
    on Mar 10, 2024
  4. typescript-bot commented on Mar 11, 2024

    @typescript-bot
    Contributor

    👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.


    Comment by rubiesonthesky

    ‼️ Exception: Error - error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. Visit https://aka.ms/ts6 for migration information.

    Error: error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
      Visit https://aka.ms/ts6 for migration information.
    
        at Object.createVirtualTypeScriptEnvironment (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:8128:11)
        at twoslasher (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:7618:17)
        at /home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:439:44
        at runTwoslashRequests (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:406:56)
        at run (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:20096:75)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    

    Historical Information
    Version Reproduction Outputs Time
    5.0.2, 5.1.3, 5.2.2, 5.3.2, 5.4.2

    ❌ Failed: -

    • Type 'Promise>>' is not assignable to type 'Promise>'. Type 'Map>' is not assignable to type 'Map'. Type 'Promise' is not assignable to type 'string'.

    ⚠️ Way slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionHas 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