microsoft / microsoft/TypeScript
[V6] `module` defaults is not `esnext`
@DanielRosenwasser arbeitet bereits daran.
Seit 01.4.2026.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
### 🔎 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`.
~~https://www.typescriptlang.org/play/?#code/FASwtgDg9gTgLgAgGZSsmUwIEQDoD0KUuAVgM5QB22CA7iHABYIDeCcAnhAKYBcO5KjQC+AbmDAAxlQoAbbrllQA5gAoiASlFA~~
### 💻 Code
- `package.json`
```json
{
"name": "testcase",
"version": "1.0.0",
"type": "module",
"dependencies": {
"typescript": "6.0.2"
}
}
```
- `index.ts`
```ts
import foo from "./foo.json" with { type: "json" };
console.log(foo);
```
1. `npm install`
2. `npc 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_](https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/#simple-default-changes), 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_](https://www.typescriptlang.org/tsconfig/#module), 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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.