Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error inferring types of promise function #17873

Open
ghost opened this issue Aug 17, 2017 · 2 comments
Open

Error inferring types of promise function #17873

ghost opened this issue Aug 17, 2017 · 2 comments
Labels
Bug A bug in TypeScript Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros
Milestone

Comments

@ghost
Copy link

ghost commented Aug 17, 2017

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

@ghost ghost added the Bug A bug in TypeScript label Aug 21, 2017
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Apr 12, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, Future Jul 2, 2018
@rubiesonthesky
Copy link

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

@typescript-bot typescript-bot added the Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros label Mar 10, 2024
@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 11, 2024

👋 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

❌ 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'.

Historical Information
Version Reproduction Outputs
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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros
Projects
None yet
Development

No branches or pull requests

4 participants