Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-unused-expression should permit await #887

Closed
andy-hanson opened this issue Dec 20, 2015 · 4 comments
Closed

no-unused-expression should permit await #887

andy-hanson opened this issue Dec 20, 2015 · 4 comments

Comments

@andy-hanson
Copy link
Contributor

The following code causes a linter error:

async function f(foo: Promise<void>): Promise<number> {
    await foo
    return 0
}

The output I get is:

src/foo.ts[2, 2]: expected an assignment or function call

Here's my tslint.json:

{
    "rules": {
        "no-unused-expression": true
    }
}
@jkillian
Copy link
Contributor

Thanks for the bug report @andy-hanson. I bet the issue comes from not handling await statements correctly. What versions of tsc does this apply to with which compiler settings? I know async/await support is still somewhat limited, correct?

@andy-hanson
Copy link
Contributor Author

This is tested with typescript 1.7.5, using tslint src/*.ts --target ES6. await foo() does work, as does const x = await foo.

@jkillian
Copy link
Contributor

jkillian commented Jan 9, 2016

@andy-hanson This is fixed on master now, and we'll likely do a release on NPM within the next week or so.

@adidahiya
Copy link
Contributor

fix is available in tslint@next (v3.2.2-dev.1)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants