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

Add module: es2022 #44653

Closed
5 tasks done
saschanaz opened this issue Jun 18, 2021 · 3 comments Β· Fixed by #44656
Closed
5 tasks done

Add module: es2022 #44653

saschanaz opened this issue Jun 18, 2021 · 3 comments Β· Fixed by #44656
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript

Comments

@saschanaz
Copy link
Contributor

Suggestion

πŸ” Search Terms

es2022

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Add module: es2022 and allow top level await in it.

πŸ“ƒ Motivating Example

Top level await

πŸ’» Use Cases

Not being required to set esnext.

Related to #44571.

saschanaz added a commit to saschanaz/TypeScript that referenced this issue Jun 18, 2021
@jimmywarting
Copy link
Contributor

Yes please! πŸ‘

TS don't do a good job at figuring out if a file runs in a type module and have no understanding that top level await can be used or not. So i think it should just be enabled by default

// index.js
var x = await Promise.resolve(0)
export default x

I'm trying to solve this without a tsconfig in plain javascript
possible with some jsdoc or other js Directives comments

But all i get is:

Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.

Is there some method to define that this file is executed as a esnext module somehow?

@RyanCavanaugh RyanCavanaugh added Committed The team has roadmapped this issue Suggestion An idea for TypeScript labels Jun 21, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 21, 2021
@DanielRosenwasser
Copy link
Member

@jimmywarting not yet, this will enable that by giving a stable target for your project.

saschanaz added a commit to saschanaz/TypeScript that referenced this issue Sep 25, 2021
DanielRosenwasser pushed a commit that referenced this issue Sep 30, 2021
@DanielRosenwasser
Copy link
Member

Thanks @saschanaz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants