Skip to content

Commit 513737f

Browse files
authored
Upgrade TypeScript to 6.0.3 (#2386)
Upgrades the monorepo from TypeScript 5.9.3 to 6.0.3, in preperation for Typescript 7. References the [official TS6 migration guide](https://aka.ms/ts6) and [privatenumber's TS6 upgrade gist](https://gist.github.com/privatenumber/3d2e80da28f84ee30b77d53e1693378f), with some help from Copilot + Clause Sonnet 4.6 to help fix errors. - Bumped `typescript` to `6.0.3` in the root and all packages that declare it as a peer dependency. - Removed `"baseUrl": "."` from tsconfig.base.json which is deprecated in TS6. **Project changes** In TS6, `compilerOptions.types` defaults to an empty array when `typeRoots` is unset, meaning ambient type packages are no longer auto-discovered. Added explicit `types` entries to each package that relies on them: - `"types": ["jest"]` - all packages with Jest tests - `"types": ["jest", "chai"]` - `react-crossword` (also uses `@vitest/expect` which references the `Chai` namespace) - `source-development-kitchen` - `"types": ["node"]` - `browserslist-config`, `newsletter-types`, `prettier`, scripts (their `tsconfig` includes `eslint.config.mjs` which transitively imports Node.js types) `@guardian/libs` - Refactored the exported anonymous class expression to a named class declaration (`StorageManager`) to fix **TS4094** ("Property of exported anonymous class type may not be private"). TS6 enforces this for private fields (`#field`) on anonymous classes. `@guardian/core-web-vitals` - FID (First Input Delay) is no longer a Core Web Vital and was [removed](https://github.com/GoogleChrome/web-vitals/blob/main/docs/upgrading-to-v5.md) from `web-vitals` in v5. Upgraded `web-vitals@4` to `5.2.0` and removed all FID references: - Removed `onFID`, `FIDMetricWithAttribution` from index.ts - Removed `fid` field from `CoreWebVitalsPayload` - Updated `LCPAttribution.element` → `.target` (renamed in v5) - Removed `INPAttribution.interactionTargetElement` (removed in v5) - Updated tests accordingly **Overrides** - `@package-json/types`: overridden to `0.0.13` as v0.0.12 has a **TS2411** bug where optional properties (`node?: string`) inside objects with `[k: string]: string` index signatures are incompatible under strict mode. This surfaced because package `tsconfig.json` files include `eslint.config.*` via `"include": ["**/*"]`, which transitively imports `eslint-plugin-import-x` → `@package-json/types`. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214972512316727
2 parents dab9e6f + 5cf4d48 commit 513737f

35 files changed

Lines changed: 349 additions & 390 deletions

File tree

.changeset/frank-pillows-go.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@guardian/source-development-kitchen': major
3+
'@guardian/identity-auth-frontend': major
4+
'@guardian/browserslist-config': major
5+
'@guardian/newsletter-types': major
6+
'@guardian/consent-manager': major
7+
'@guardian/core-web-vitals': major
8+
'@guardian/react-crossword': major
9+
'@guardian/eslint-config': major
10+
'@guardian/identity-auth': major
11+
'@guardian/ab-react': major
12+
'@guardian/prettier': major
13+
'@guardian/ab-core': major
14+
'@guardian/source': major
15+
'@guardian/libs': major
16+
'@guardian/tsconfig': major
17+
---
18+
19+
Update Typescript to v6 (6.0.3):
20+
21+
- Use https://gist.github.com/privatenumber/3d2e80da28f84ee30b77d53e1693378f as a reference to update your own codebase to TS6.
22+
- If you use `ts-jest` to run jest tests, update to v29.4.11 minimum to ensure compatibility with TS6.

apps/github-pages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@guardian/libs": "workspace:*",
1717
"astro": "6.3.3",
1818
"svelte": "5.55.7",
19-
"typescript": "5.9.3",
19+
"typescript": "6.0.3",
2020
"wireit": "0.14.12"
2121
},
2222
"wireit": {

libs/@guardian/ab-core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
"jest": "30.4.2",
3737
"jest-environment-jsdom": "30.4.1",
3838
"rollup": "4.60.0",
39-
"ts-jest": "29.4.0",
39+
"ts-jest": "29.4.11",
4040
"tslib": "2.8.1",
41-
"typescript": "5.9.3",
41+
"typescript": "6.0.3",
4242
"wireit": "0.14.12"
4343
},
4444
"peerDependencies": {
4545
"tslib": "^2.8.1",
46-
"typescript": "~5.9.3"
46+
"typescript": "~6.0.3"
4747
},
4848
"peerDependenciesMeta": {
4949
"typescript": {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"extends": "../../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"types": ["jest"]
5+
},
36
"include": ["**/*"],
47
"exclude": ["node_modules", "dist", ".wireit", "jest.dist.setup.js"]
58
}

libs/@guardian/ab-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
"react": "18.2.0",
4343
"react-dom": "18.2.0",
4444
"rollup": "4.60.0",
45-
"ts-jest": "29.4.0",
45+
"ts-jest": "29.4.11",
4646
"tslib": "2.8.1",
47-
"typescript": "5.9.3",
47+
"typescript": "6.0.3",
4848
"wireit": "0.14.12"
4949
},
5050
"peerDependencies": {
@@ -53,7 +53,7 @@
5353
"react": "^18.2.0",
5454
"react-dom": "^18.2.0",
5555
"tslib": "^2.8.1",
56-
"typescript": "~5.9.3"
56+
"typescript": "~6.0.3"
5757
},
5858
"peerDependenciesMeta": {
5959
"@types/react": {

libs/@guardian/ab-react/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"include": ["**/*"],
44
"exclude": ["node_modules", "dist", ".wireit", "jest.dist.setup.js"],
55
"compilerOptions": {
6-
"jsxImportSource": "react"
6+
"jsxImportSource": "react",
7+
"types": ["jest"]
78
}
89
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"extends": "../../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"types": ["node"]
5+
},
36
"include": ["**/*"],
47
"exclude": ["node_modules", "dist", ".wireit"]
58
}

libs/@guardian/consent-manager/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
"jest-fetch-mock": "3.0.3",
4747
"mockdate": "3.0.5",
4848
"rollup": "4.60.0",
49-
"ts-jest": "29.4.0",
49+
"ts-jest": "29.4.11",
5050
"tslib": "2.8.1",
5151
"tsx": "4.22.1",
52-
"typescript": "5.9.3",
52+
"typescript": "6.0.3",
5353
"wcag-contrast": "3.0.0",
5454
"wireit": "0.14.12"
5555
},
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"extends": "../../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"types": ["jest"]
5+
},
36
"include": ["**/*", "../../../@types/window.d.ts"],
47
"exclude": ["node_modules", "dist", ".wireit", "jest.dist.setup.js"]
58
}

libs/@guardian/core-web-vitals/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
"jest": "30.4.2",
3737
"jest-environment-jsdom": "30.4.1",
3838
"rollup": "4.60.0",
39-
"ts-jest": "29.4.0",
39+
"ts-jest": "29.4.11",
4040
"tslib": "2.8.1",
41-
"typescript": "5.9.3",
42-
"web-vitals": "4.2.1",
41+
"typescript": "6.0.3",
42+
"web-vitals": "5.2.0",
4343
"wireit": "0.14.12"
4444
},
4545
"peerDependencies": {
4646
"@guardian/libs": "^32.0.0",
4747
"tslib": "^2.8.1",
48-
"typescript": "~5.9.3",
49-
"web-vitals": "^4.2.1"
48+
"typescript": "~6.0.3",
49+
"web-vitals": "^5.2.0"
5050
},
5151
"peerDependenciesMeta": {
5252
"typescript": {

0 commit comments

Comments
 (0)