-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
4.7-beta nodenext, .cts compiles to CJS, but code can be ES6 module #48809
Comments
I just had this same issue and setting es2022 works whereas nodenext doesnt |
@robogeek please post your full tsconfig.json |
This is for a directory which is meant to be rendered as ES6 format. However, I believe the
Same happens if I use Setting it to Remember that, Node.js requires that |
Duplicate of #48835 |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Doesn't seems like a duplicate of #48835 In this issue, we are expecting |
Bug Report
I read the 4.7.0-beta announcement on the Microsoft devblogs, and am trying to replicate the new behavior for file extensions. I created a test package, where the source files are
cts.cts
,index.ts
, andmts.mts
. I am expecting the first to be transpiled to CJS format in all cases, the last to transpile to ES6 format in all cases, and forindex.ts
to transpile to either CJS or ES6 format depending on the setting ofmodule
intsconfig.json
.Instead ... the files do get named as expected, as
cts.cjs
, andindex.js
, andmts.mjs
.However, the content of these files are in either CJS or ES6 format depending on
module
intsconfig.json
.🔎 Search Terms
On DuckDuckGo, I used "typescript nodenext" and found a StackOverflow question that was useful.
On GitHub, I simply put "nodenext".
🕗 Version & Regression Information
⏯ Playground Link
N/A
💻 Code
The code is not important to the bug report. But, the three files named above all have the same source, which is this wonderful piece of coding:
🙁 Actual behavior
As discussed above, the file names become
cts.cjs
, andindex.js
, andmts.mjs
.If the
module
tag intsconfig.json
is set toes2022
, all these files transpile to ES6 format.If the
module
tag is set tonodenext
, all these files transpile to CJS format.🙂 Expected behavior
I am expecting that with
module
set tonodenext
thatcts.cts
transpiles tocts.cjs
in CJS,index.ts
transpiles toindex.js
in ES6 format, andmts.mts
transpiles tomts.mjs
in ES6 format.For other settings of
module
the.cts
and.mts
should possibly throw errors since that's what the blog post says.The text was updated successfully, but these errors were encountered: