Skip to content

Compiler not erroring for generic in Promise.resolve #10785

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

Closed
OliverJAsh opened this issue Sep 8, 2016 · 4 comments
Closed

Compiler not erroring for generic in Promise.resolve #10785

OliverJAsh opened this issue Sep 8, 2016 · 4 comments

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Sep 8, 2016

Latest 2 beta

type Foo = Promise<string>;
const baz = Promise.resolve(1); // inferred as Promise<number>, correct
const cmd: Foo = baz // should error! number should be string
@yortus
Copy link
Contributor

yortus commented Sep 9, 2016

It is an annoying problem, but I think the team is looking into it. See #9953 and #10524. (This is really a duplicate of those).

@OliverJAsh
Copy link
Contributor Author

Closed by 9d4219a

@OliverJAsh
Copy link
Contributor Author

Actually I believe this is still an issue:

const commits: Promise<number> = Promise.resolve('foo') // no error!

@mhegazy
Copy link
Contributor

mhegazy commented Dec 14, 2016

Actually I believe this is still an issue:

should be working now.

c:\test>tsc --v
Version 2.1.4

c:\test>type C:\test\sandbox8\a.ts
const commits: Promise<number> = Promise.resolve('foo') // no error!

c:\test>tsc C:\test\sandbox8\a.ts --lib es6
sandbox8/a.ts(1,7): error TS2322: Type 'Promise<string>' is not assignable to type 'Promise<number>'.
  Type 'string' is not assignable to type 'number'.

@mhegazy mhegazy closed this as completed Dec 14, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants