Skip to content

Forgotten 'await' error doesn't account for strictPropertyInitialization #43071

Description

We recently ran into some breaks in #43004 (comment) as a result of #25330; however, I think this might be a bigger change than we anticipate.

For one, we don't check whether the value is used after checking the value. For another, we don't really think about class properties, which aren't reliable unless using strictPropertyInitialization.

// @strictNullChecks: true// @strictPropertyInitialization: falseclassC{yadda: Promise<number>;asyncdoStuff(){this.yadda=Promise.resolve(42);}}asyncfunctionf(){letobj=newC();if(obj.yadda){awaitobj.yadda;}letx=newC().yadda;if(x){awaitx;}}

Finally, there's some sort of bug where this is plainly giving false positives.

letx: Promise<string>;setTimeout(()=>{x=Promise.resolve("");})setTimeout(()=>{// this should NOT be an errorif(x){x;}})

I guess the question is: should these be errors?

Activity

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

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions