Skip to content

async arrow function masks "Promise is not defined" errors. #37521

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
DanielRosenwasser opened this issue Mar 23, 2020 · 2 comments
Closed

async arrow function masks "Promise is not defined" errors. #37521

DanielRosenwasser opened this issue Mar 23, 2020 · 2 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@DanielRosenwasser
Copy link
Member

// foo.ts
/*start*/(async (a) => {
})/*end*/

Promise.all([]);
{
  "compilerOptions": {
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "strict": true,                           /* Enable all strict type-checking options. */
  }
}
  1. Open up an editor session

Expected

'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.ts(2585)

Actual

No errors!!!

Try deleting from /*start*/ to /*end*/ and you correctly get an error!

@DanielRosenwasser DanielRosenwasser changed the title Single async function masks "Promise is not defined" errors. async arrow function masks "Promise is not defined" errors. Mar 23, 2020
@DanielRosenwasser
Copy link
Member Author

DanielRosenwasser commented Mar 23, 2020

First time this behavior is observable is [email protected]. I suspect that this is also related to #37522.

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Mar 23, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.1 milestone Mar 23, 2020
@sandersn
Copy link
Member

Like #37522, no longer repros on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants