-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Docs: Difference between esnext, es6, es2015 module targets #24082
Comments
To just answer the question, the difference is that I guess you could possibly expect an |
in addition to what @DanielRosenwasser mentioned, Also |
Is there a place where I can see the list of https://github.com/tc39/proposals syntax supported? |
You can find all the libs and supported features in this folder: https://github.com/Microsoft/TypeScript/tree/master/lib |
The only place that I found for understanding TS support is here, but this table is misleading... "red" doesn't mean that TS doesn't support the feature, it means that it doesn't run on previous version of JavaScript... yea, misleading. Can we create a similar solution for TS, but with real supported/unsupported table? (With relation to the |
Is there someone who can give a detail explanation for |
Is targeting |
@vegerot |
I wish |
If you're looking for stability, you may want to hold off on using |
If, say the end result we send to users is ES2016 compatible (say, through Babel), does it make sense to target ES2016 and then pipe through the other compiler? Or to target ESNext and pipe it through the other compiler (assuming the other compiler supports ESNext)? |
If you're targeting a minimally ES2016 environment (most modern browsers, most recent versions of Node) then there's no need to pipe through Babel except for auto-polyfills. If you need auto-polyfilling, emit to ESNext and pipe through Babel. If not, just emit to ES2016 with TypeScript. |
tsconfig.json module options: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext',what's different of 'es2020', or 'ESNext'? |
@scarcoco I am guessing from reading this that es2020 is when the import() and import.meta landed. I am just guessing though. ESNext is all the new features that have not been finalized yet. there may or may not be any difference between that and es2020 at the time of writing but in the future when more features are inevitably added to the module system ESNext would include those. |
Top-level await was included in ECMAScript 2022, see https://github.com/tc39/proposals/blob/main/finished-proposals.md But there is no It's not clear for me why there is no |
- it's already been supported since eb1dd17, but the docs and error message were not updated to mention it - so add both to make sure users aren't confused - also re-order it to be ES2015, ES2020, then ESNext consistently, which is their module order (c.f. microsoft/TypeScript#24082) - modify test to account for the new error message - make it a bit more resilient to change by only testing a substring as well (c.f. https://jestjs.io/docs/expect#tothrowerror)
- it's already been supported since eb1dd17, but the docs and error message were not updated to mention it - so add both to make sure users aren't confused - also re-order it to be ES2015, ES2020, then ESNext consistently, which is their module order (c.f. microsoft/TypeScript#24082) - modify test to account for the new error message - make it a bit more resilient to change by only testing a substring as well (c.f. https://jestjs.io/docs/expect#tothrowerror)
- it's already been supported since eb1dd17, but the docs and error message were not updated to mention it - so add both to make sure users aren't confused - also re-order it to be ES2015, ES2020, then ESNext consistently, which is their module order (c.f. microsoft/TypeScript#24082) - modify test to account for the new error message - make it a bit more resilient to change by only testing a substring as well (c.f. https://jestjs.io/docs/expect#tothrowerror)
I recently noticed that import assertions are supported with module @thernstig it looks like
|
New module docs are live at https://www.typescriptlang.org/docs/handbook/2/modules.html |
I'd suggest the following link: https://www.typescriptlang.org/tsconfig#module |
I'd suggest this docs: https://www.typescriptlang.org/docs/handbook/modules/theory.html#the-module-output-format |
Search Terms
esnext, es6, es2015, module, tsconfig, tsconfig.json, difference, document
Suggestion
It would be great if this can be documented. On the face of it, the output for all three seems to be identical.
Related: It would also be nice to document why targeting
module: "none"
when your code is a module (ie. uses ES2015 imports/exports) generates CommonJS-compatible code instead of exporting to globals as "none" seems to imply.The text was updated successfully, but these errors were encountered: