Skip to content

Upgrade and simplify root tsconfig for Node.js 22#4072

Open
ddbeck wants to merge 1 commit into
web-platform-dx:mainfrom
ddbeck:simplify-root-tsconfig/ktzqvlvzxtks
Open

Upgrade and simplify root tsconfig for Node.js 22#4072
ddbeck wants to merge 1 commit into
web-platform-dx:mainfrom
ddbeck:simplify-root-tsconfig/ktzqvlvzxtks

Conversation

@ddbeck
Copy link
Copy Markdown
Collaborator

@ddbeck ddbeck commented May 26, 2026

Summary

This turns on some JavaScript language features and cleans up some longstanding quirks in our TypeScript config.

Background

When we upgraded to Node.js 22, we didn't change the TypeScript config, so the type checker won't actually let you use any of the new JavaScript niceties in this version of Node.

On top of that, our root tsconfig.json file is a little unconventional (there are other PRs and issues open about this, though this PR doesn't address all of it).

What's new here

This PR does a few little things:

  • To minimize weirdness, uses Microsoft's recommended base configurations from tsconfig/bases for Node.js 22 and Node.js + Typescript, so the things that we're doing that are unusual stand out in the tsconfig.json file. Then, as a consequence, the three following things.
  • Uses .ts import extensions, exclusively, in our project scripts.
  • Uses explicit type imports, where applicable. This is more explicit and will help us drop a dependency in the future.
  • Fixes the remaining type errors that resulted.

Finally, this only touches the root tsconfig.json. There is some related work to do in the packages/ directories, but to make this PR easier to review, I elected to do those in follow up PRs.

Related PRs

@github-actions github-actions Bot added the tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings label May 26, 2026
Copy link
Copy Markdown
Collaborator Author

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guided tour for the actual reviewer.

Comment thread scripts/build.ts
Comment on lines -1 to +11
import { DefinedError } from "ajv";
import type { DefinedError } from "ajv";
import stringify from "fast-json-stable-stringify";
import { fdir } from "fdir";
import { execSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import winston from "winston";
import yargs from "yargs";
import * as data from "../index.js";
import { validate, validateProposed } from "./validate.js";
import { fdir } from "fdir";
import YAML from "yaml";
import yargs from "yargs";
import * as data from "../index.ts";
import { validate, validateProposed } from "./validate.ts";
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My editor sorted these imports. Let me know if you want me to revert this.

Comment on lines 18 to +101
@@ -94,7 +98,7 @@ function getNotes(compatKey: string): Map<string, string[]> {
const f = feature(compatKey);
for (const browserKey of coreBrowserSet) {
const statements = f
.supportStatements(defaultCompat.browser(browserKey))
.supportStatements(compat.browser(browserKey))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package doesn't actually export defaultCompat, which makes the type checker mad. These two change fix that problem.

Comment thread tsconfig.json
"strict": false
},
"exclude": ["packages/", "gh-pages/"]
"exclude": ["packages/"]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh-pages/ doesn't exist anymore.

Comment thread tsconfig.json
Comment on lines +2 to +5
"extends": [
"@tsconfig/node22/tsconfig.json",
"@tsconfig/node-ts/tsconfig.json"
],
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the big difference. We only set the options specific to this project (e.g., noEmit), then accept recommended defaults for our runtime.

@ddbeck ddbeck mentioned this pull request May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants