Update TypeScript to 6.0.3 with stable type ordering#7792
Update TypeScript to 6.0.3 with stable type ordering#7792
Conversation
Agent-Logs-Url: https://github.com/primer/react/sessions/a15a55df-6d49-4490-a348-a8408f1765f1 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/a15a55df-6d49-4490-a348-a8408f1765f1 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/a15a55df-6d49-4490-a348-a8408f1765f1 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/a15a55df-6d49-4490-a348-a8408f1765f1 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/a15a55df-6d49-4490-a348-a8408f1765f1 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/a15a55df-6d49-4490-a348-a8408f1765f1 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
|
|
There was a problem hiding this comment.
Pull request overview
This pull request updates the monorepo’s TypeScript toolchain to TypeScript 6.0.3 and adjusts related configuration and type declarations to keep type-checking, CSS side-effect imports, and doc generation working across workspaces.
Changes:
- Bump TypeScript (and related tooling like
typescript-eslint) to versions compatible with TS 6. - Add Node type support in shared TS configs and add
@types/nodeat the repo root. - Add
*.cssmodule declarations for side-effect CSS imports and adjust doc-gen TS config resolution.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds explicit Node types for root TS usage and reformats include list. |
| tsconfig.base.json | Adds types: ["node"] to the shared compiler options. |
| package.json | Updates TypeScript + typescript-eslint and adds @types/node dev dependency. |
| package-lock.json | Lockfile updates reflecting TS 6 / tooling upgrades and new dependency resolutions. |
| packages/react/tsconfig.build.json | Adds explicit rootDir for declaration-only build output. |
| packages/react/src/global.d.ts | Adds declare module '*.css' {} to allow side-effect CSS imports. |
| packages/react/package.json | Updates workspace TypeScript dependency to ^6.0.3. |
| packages/doc-gen/src/ts-utils.ts | Adjusts tsconfig discovery/parse to use an absolute search dir / config path. |
| packages/doc-gen/package.json | Updates workspace TypeScript dependency to ^6.0.3. |
| packages/mcp/package.json | Updates workspace TypeScript dependency to ^6.0.3. |
| packages/postcss-preset-primer/package.json | Updates workspace TypeScript dependency to ^6.0.3. |
| packages/rollup-plugin-import-css/package.json | Updates workspace TypeScript dependency to ^6.0.3. |
| packages/styled-react/package.json | Updates workspace TypeScript dependency to ^6.0.3. |
| packages/styled-react/.storybook/global.d.ts | Adds *.css module declaration for Storybook side-effect CSS imports. |
| examples/nextjs/package.json | Updates example TypeScript dependency to ^6.0.3. |
| examples/nextjs/global.d.ts | Adds *.css module declaration for side-effect CSS imports. |
| examples/theming/package.json | Updates example TypeScript dependency to ^6.0.3. |
| examples/theming/global.d.ts | Adds *.css module declaration for side-effect CSS imports. |
| examples/codesandbox/package.json | Updates example TypeScript dependency to ^6.0.3. |
Copilot's findings
- Files reviewed: 13/19 changed files
- Comments generated: 3
| const configSearchDir = rootDir ? path.resolve(rootDir) : process.cwd() | ||
| const configPath = ts.findConfigFile(configSearchDir, ts.sys.fileExists) | ||
| const config = ts.readConfigFile(configPath ?? 'tsconfig.json', ts.sys.readFile) | ||
| const parsedConfig = ts.parseJsonConfigFileContent( | ||
| config.config, | ||
| ts.sys, | ||
| configPath ? path.dirname(configPath) : process.cwd(), | ||
| undefined, | ||
| 'tsconfig.json', | ||
| configPath ?? path.join(process.cwd(), 'tsconfig.json'), | ||
| ) |
There was a problem hiding this comment.
getTSProgram computes configSearchDir from rootDir, but the fallback paths still use process.cwd() (both the readConfigFile filename and the parseJsonConfigFileContent base/configFileName args). If rootDir is provided and no tsconfig is found, this will read/resolve the wrong config relative to the current working directory instead of the requested root. Use configSearchDir for the fallback (or throw when configPath is undefined) so doc-gen resolves configs deterministically.
See below for a potential fix:
const fallbackConfigPath = path.join(configSearchDir, 'tsconfig.json')
const config = ts.readConfigFile(configPath ?? fallbackConfigPath, ts.sys.readFile)
const parsedConfig = ts.parseJsonConfigFileContent(
config.config,
ts.sys,
configPath ? path.dirname(configPath) : configSearchDir,
undefined,
configPath ?? fallbackConfigPath,
There was a problem hiding this comment.
Addressed in 0a431f5 by resolving the fallback tsconfig path and parse base from configSearchDir instead of process.cwd().
| "typescript": "^6.0.3", | ||
| "typescript-eslint": "^8.59.1", |
There was a problem hiding this comment.
typescript-eslint@8.59.1 declares a Node engine requirement (>=18.18.0 / >=20.9.0 / >=21.1.0). Since this repo’s root package.json still advertises a much lower Node engine, installing with older Node versions will produce engine warnings/failures. Consider updating the repo’s documented/declared Node engine range to match the new tooling requirements.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/4ca05341-a404-4579-8d24-8c084938d197 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/b75b5f39-2273-4b97-942b-33291bcfdd06 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/b75b5f39-2273-4b97-942b-33291bcfdd06 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot resolve the merge conflicts in this pull request |
Agent-Logs-Url: https://github.com/primer/react/sessions/f4d835bb-e8b4-4459-a1e2-06c8716f84c8 Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Resolved the merge conflicts in 94dcef8 by merging Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Update TypeScript to v6
Updates TypeScript to 6.0.3 across the monorepo workspaces and updates related tooling compatibility. Adds the TypeScript 6 compatibility fixes needed for type-checking, CSS side-effect imports, doc generation, and stable type ordering to support future TypeScript 6.0 to 7.0 migrations.
Changelog
New
stableTypeOrderingin shared compiler options.Changed
typescript-eslintto 8.59.1 for TypeScript 6 support.@types/nodedev dependency and explicit Node types in shared TypeScript config.rootDirand scopedincludefor the React package declaration build config.main, keeping the TypeScript 6 tooling updates and the newer Vitest 4.1.5-related versions frommain.Removed
Rollout strategy
Testing & Reviewing
Validated with:
npm run type-checknpm run buildnpm run lintnpm run lint:cssnpm run format:diffnpm test -- packages/react/src/TreeView/TreeView.test.tsxnpm test -- packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsxMerge checklist