Build Tools: Update TypeScript to 6.0.2#77010
Conversation
Add generic `*.css` and `*.scss` ambient module declarations alongside the existing `*.module.css` and `*.module.scss` declarations. TypeScript 6 introduces TS2882 which errors on side-effect imports of stylesheets without type declarations. Also update all tsconfig references to use the new name.
TypeScript 6 includes proper typings for `Intl.Locale.getTextInfo()`, making the `@ts-expect-error` directive unused (TS2578). Use optional chaining as a runtime fallback for older browsers.
Add --ignoreConfig flag (TS6 errors when tsconfig.json exists and files are passed on CLI) and switch --moduleResolution from deprecated node10 to bundler.
The esModuleInterop option is deprecated in TypeScript 6. The default value is already false, so removing it preserves existing behavior.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -2 B (0%) Total Size: 7.74 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 0735e45. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23916347646
|
Auto-generated docs reflect minor type signature differences in TS6 (e.g. parenthesized function types, explicit null/undefined unions).
Co-authored-by: Andrew Duthie <1779930+aduth@users.noreply.github.com>
* Build Tools: Update TypeScript from 5.9.3 to 6.0.2 * Build Tools: Rename typings/css-modules to typings/style-imports Add generic `*.css` and `*.scss` ambient module declarations alongside the existing `*.module.css` and `*.module.scss` declarations. TypeScript 6 introduces TS2882 which errors on side-effect imports of stylesheets without type declarations. Also update all tsconfig references to use the new name. * Components: Remove @ts-expect-error for Intl.Locale.getTextInfo TypeScript 6 includes proper typings for `Intl.Locale.getTextInfo()`, making the `@ts-expect-error` directive unused (TS2578). Use optional chaining as a runtime fallback for older browsers. * Build Tools: Fix type declaration check script for TypeScript 6 Add --ignoreConfig flag (TS6 errors when tsconfig.json exists and files are passed on CLI) and switch --moduleResolution from deprecated node10 to bundler. * Build Tools: Remove deprecated esModuleInterop from tsconfig The esModuleInterop option is deprecated in TypeScript 6. The default value is already false, so removing it preserves existing behavior. * Components: Regenerate README docs for TypeScript 6 type changes Auto-generated docs reflect minor type signature differences in TS6 (e.g. parenthesized function types, explicit null/undefined unions). * Remove unnecessary optional chaining --------- Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
| } | ||
|
|
||
| declare module '*.css'; | ||
| declare module '*.scss'; |
| "moduleResolution": "bundler", | ||
|
|
||
| /* This needs to be false so our types are possible to consume without setting this */ | ||
| "esModuleInterop": false, |
There was a problem hiding this comment.
We still have some esModuleInterop: true declaration in a few tsconfig.base.json. If this option is going to be completely removed in TS 7.0, we should remove them, too. So that we are prepared.
* Build Tools: Update TypeScript from 5.9.3 to 6.0.2 * Build Tools: Rename typings/css-modules to typings/style-imports Add generic `*.css` and `*.scss` ambient module declarations alongside the existing `*.module.css` and `*.module.scss` declarations. TypeScript 6 introduces TS2882 which errors on side-effect imports of stylesheets without type declarations. Also update all tsconfig references to use the new name. * Components: Remove @ts-expect-error for Intl.Locale.getTextInfo TypeScript 6 includes proper typings for `Intl.Locale.getTextInfo()`, making the `@ts-expect-error` directive unused (TS2578). Use optional chaining as a runtime fallback for older browsers. * Build Tools: Fix type declaration check script for TypeScript 6 Add --ignoreConfig flag (TS6 errors when tsconfig.json exists and files are passed on CLI) and switch --moduleResolution from deprecated node10 to bundler. * Build Tools: Remove deprecated esModuleInterop from tsconfig The esModuleInterop option is deprecated in TypeScript 6. The default value is already false, so removing it preserves existing behavior. * Components: Regenerate README docs for TypeScript 6 type changes Auto-generated docs reflect minor type signature differences in TS6 (e.g. parenthesized function types, explicit null/undefined unions). * Remove unnecessary optional chaining --------- Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
What?
Supersedes #77009
Update TypeScript from 5.9.3 to 6.0.2 and fix all resulting build issues.
Why?
TypeScript 6 is the latest stable major version, bringing improved type checking (e.g. proper
Intl.Locale.getTextInfo()typings), stricter side-effect import validation, and deprecation of legacy options.How?
package.json.typings/css-modules→typings/style-imports— add generic*.cssand*.scssambient module declarations alongside the existing*.module.css/*.module.scssdeclarations. TS6 introduces TS2882 which errors on side-effect stylesheet imports without type declarations. Updated all tsconfig references.use-localization-props.ts— TS6 now typesIntl.Locale.getTextInfo(), making the@ts-expect-errordirective unused (TS2578). Use optional chaining as a runtime fallback.check-build-type-declaration-files.js— add--ignoreConfigflag (TS6 TS5112) and switch--moduleResolutionfrom deprecatednode10tobundler.esModuleInterop: falsefromtsconfig.base.json— deprecated in TS6, default is alreadyfalse.Testing Instructions
npm run build— should complete successfully.npx tsc --noEmit— zero errors.tsconfig.jsonin an IDE — no deprecation warnings.Testing Instructions for Keyboard
N/A — no UI changes.
Use of AI Tools
This PR was authored with the assistance of Claude Code (claude-opus-4-6).