Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/typescript-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": minor
---

Support TypeScript 7 in the TypeScript check. TypeScript 7 has no compiler API in JavaScript, so the check failed to load it at all. The check now runs the native compiler through the API TypeScript 7 ships (`typescript/unstable/async`), in a process of its own that stays open while webpack watches and is told which files webpack saw change. It prints diagnostics the way `tsc --pretty` does. `build`, a writing `mode`, and compiler options written in the plugin are reported as unsupported under TypeScript 7. Over 600 files, a one-shot build went from 3.5 s on TypeScript 6 to 1.4–1.5 s, and a watch rebuild from 1.0–2.5 s to 0.7–0.8 s.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,8 @@ Not `--reporter`: the check asks for JSON and formats the results itself.

## TypeScript

Run with `{ use: "typescript" }`, and requires `typescript >= 5`. It type checks
Run with `{ use: "typescript" }`, and requires `typescript >= 5` (see
[TypeScript 7](#typescript-7) for the native compiler). It type checks
the program a `tsconfig.json` describes, so every file that config includes is
checked whether or not webpack built it, and a type error in a module nothing
imports yet is still reported. Emit is forced off: webpack writes the output.
Expand Down Expand Up @@ -893,6 +894,26 @@ new DiagnosticsPlugin({
});
```

### TypeScript 7

TypeScript 7 is a native compiler with no compiler API in JavaScript, so the
check talks to it through the API it ships instead (`typescript/unstable/async`).
It runs in a process of its own, which takes the place of
[`threads`](#threads), and is kept open while webpack watches: a rebuild tells it
which files webpack saw change. What it prints is what `tsc --pretty` prints.

It checks the project as its config file describes it, so [`build`](#build), a
[`mode`](#mode) that writes, and compiler options written in the plugin are
reported as unsupported rather than ignored. Compiler options belong in the
`tsconfig.json` instead; `build` and a writing `mode` have no TypeScript 7
counterpart.

Over 600 files, a one-shot build with the check went from 3.5 s to 1.4–1.5 s
next to TypeScript 6, and webpack's own process from 6.4 to 0.6–0.8 s of CPU and
from 383 to 108 MB at its peak; the native compiler, checking the same project
on its own, takes 1.5–1.7 s of CPU. A rebuild after an edit went from 1.0–2.5 s
to 0.7–0.8 s.

### `typescriptPath`

- Type:
Expand Down
Loading
Loading