Skip to content

Promises are not checked for null/undefined on assignment #14605

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
wkrueger opened this issue Mar 12, 2017 · 2 comments
Closed

Promises are not checked for null/undefined on assignment #14605

wkrueger opened this issue Mar 12, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@wkrueger
Copy link

TS version: 2.2.1
strict null checks on

Is this desired/expected behavior?

let p1: Promise<number|undefined> = Promise.resolve(undefined)
let p2: Promise<number>

p2 = p1
//no error. Expected "cannot assign number|undefined to number" 
@wkrueger wkrueger changed the title Promises are not checked for null/undefined results Promises are not checked for null/undefined on assignment Mar 12, 2017
@ahejlsberg
Copy link
Member

Duplicate of #13513. We still thinking about the best way to resolve this issue.

@ahejlsberg ahejlsberg added the Duplicate An existing issue was already created label Mar 12, 2017
@wkrueger
Copy link
Author

thx!
applying the "branding" workaround for now, just found it from #9953

interface Promise<T> { __promiseBrand: T }

@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants