microsoft / microsoft/TypeScript
[V6] `module` defaults is not `esnext`
@DanielRosenwasser ya está trabajando en esto.
Desde el 1/4/2026.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
🔎 Search Terms
"module", "default", "esnext", "v6"
🕗 Version & Regression Information
This changed between versions V5 and V6
⏯ Playground Link
This isn't an issue in Playground, because you're required to enter a value for the module.
💻 Code
-
package.json{ "name": "testcase", "version": "1.0.0", "type": "module", "dependencies": { "typescript": "6.0.2" } } -
index.tsimport foo from "./foo.json" with { type: "json" }; console.log(foo);
npm installnpc tsc index.ts
🙁 Actual behavior
index.ts:1:30 - error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'node20', 'nodenext', or 'preserve'.
1 import foo from "./foo.json" with { type: "json" };
~~~~~~~~~~~~~~~~~~~~~
🙂 Expected behavior
No error because module defaults to esnext.
Additional information about the issue
In Announcing TypeScript 6.0, it says module defaults to esnext: Similarly, the new default module is esnext, acknowledging that ESM is now the dominant module format.
But in TSConfig Reference, it's CommonJS if target is ES5; ES6/ES2015 otherwise.
In the code, I don't think the default value is esnext. Otherwise, we wouldn't be getting the TS2823 error.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.