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

【BUG】"await" should be a type error other than "Promise" #14976

Closed
kgtkr opened this issue Apr 2, 2017 · 5 comments
Closed

【BUG】"await" should be a type error other than "Promise" #14976

kgtkr opened this issue Apr 2, 2017 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@kgtkr
Copy link

kgtkr commented Apr 2, 2017

BUG

TypeScript Version:2.1.6

Code

//example
(async()=>{
  await 1;
  await "";
  await new Date();
  await [];
  await null;
  await undefined;
})();

Expected behavior:Type error

Actual behavior:Successful compilation

@aluanhaddad
Copy link
Contributor

But that is OK. See the behavior of await as documented
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
Specifically MDN states that:

If the value is not a Promise, it converts the value to a resolved Promise, and waits for it.

@ghost
Copy link

ghost commented Apr 2, 2017

Tslint has a rule for this. https://palantir.github.io/tslint/rules/await-promise/

@aluanhaddad
Copy link
Contributor

Thank you. I am going to go turn that on.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 2, 2017
@RyanCavanaugh
Copy link
Member

Previously discussed at #8310 and #9921

@kgtkr
Copy link
Author

kgtkr commented Apr 3, 2017

I understand.
Thank you.

@microsoft microsoft locked and limited conversation to collaborators Jun 21, 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

3 participants