Commit 513737f
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/121497251231672735 files changed
Lines changed: 349 additions & 390 deletions
File tree
- .changeset
- apps/github-pages
- libs/@guardian
- ab-core
- ab-react
- browserslist-config
- consent-manager
- core-web-vitals
- src
- @types
- eslint-config
- identity-auth-frontend
- identity-auth
- libs
- src/storage
- newsletter-types
- prettier
- react-crossword
- source-development-kitchen
- source
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
0 commit comments