Skip to content

chore: upgrade TypeScript to 7.0.2 across the workspace - #609

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/typescript-7-upgrade-3a545d
Aug 5, 2026
Merged

chore: upgrade TypeScript to 7.0.2 across the workspace#609
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/typescript-7-upgrade-3a545d

Conversation

@zachdunn

@zachdunn Zach Dunn (zachdunn) commented Aug 5, 2026

Copy link
Copy Markdown
Member

What

Moves 11 of 12 workspace packages to TypeScript 7.0.2, the native Go compiler. apps/web is the sole holdout, for a reason upstream controls.

Typecheck on apps/api drops from ~2.2s to ~1.1s. The wins are modest at this repo's size; the real value is being on the supported line before the ecosystem moves.

The constraint that shapes this PR

TypeScript 7's npm package no longer ships the JS compiler API. Its main export is just lib/version.cjs:

exports.version = version;
exports.versionMajorMinor = "7.0";

ts.createProgram, ts.sys, and the language service now live behind typescript/unstable/*. Any tool that does import ts from "typescript" and calls compiler APIs breaks at runtime. Using tsc as a CLI is fully supported — only the JS-API import path is affected.

Two packages used such tools. Each was handled on its merits rather than pinned by default.

packages/ui — upgraded (build tool changed)

Nothing about this package required an old TypeScript; only tsup's dts: true did, since it generates declarations through rollup-plugin-dts. tsc emits declarations directly, so tsup now builds only the JS bundle:

build: "tsup" → "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist"
dts:   true   → false

This also lifts the package off a stale 5.6.3 pin, two majors behind the rest of the repo.

Declaration output changes from one bundled index.d.ts to per-file .d.ts (12 files). astro check resolves them cleanly — 150 files, 0 errors.

apps/web — stays on ^6.0.3

@astrojs/check@0.9.10 (latest) declares a peer of typescript: "^5.0.0 || ^6.0.0". TS7 is excluded upstream, so this is not a version lag a bump can fix.

Workarounds were tested, not assumed:

  • astro build works on TS7 (exit 0) — it runs through esbuild/vite and never touches the TS API. Only astro check breaks.
  • Aliasing a second TypeScript fails: pnpm resolves a peer dep from the host package, so @astrojs/check would still receive 7. It would require a real typescript@6 plus an alias whose tsc bin collides in .bin, invoked by absolute path.

The payoff wouldn't justify that complexity anyway. tsconfig.worker.json — web's only direct tsc use — covers 4 files; astro check covers 149. Upgrading would speed up 4 files and break type coverage on 149.

Tracked in #610 — revisit when Astro ships TS7 support; it becomes a one-line change.

Behavior changes encountered

TypeScript 7 rejects an inferred rootDir (TS5011), so the declaration emit needs it explicitly. This is the only TS7-specific code change in the PR.

Incidental fix

packages/ui/tsup.config.ts imports node:fs but sat outside every tsconfig include, so it had no program and type-aware lint on it failed. This predates this PR — the original file fails identically — and surfaced only because the file is touched here.

Fixed by splitting the config: tsconfig.json now covers src plus tsup.config.ts (typecheck + lint), and a new tsconfig.build.json carries rootDir for the emit. @types/node added at ^26.1.0, matching the six other packages. Net effect: tsup.config.ts is now typechecked, where before it wasn't.

Verification

Check Result
pnpm typecheck (13 projects) exit 0
astro check 150 files, 0 errors
pnpm test 270 files, 3798 tests passed
pnpm build (web) exit 0
pnpm check (lint + format) exit 0
CLI build (@buildinternet/uploads) exit 0, valid .d.ts

A sweep for other fallout found none: no first-party typescript imports anywhere, all tsconfigs already on module: ESNext + moduleResolution: bundler with none of the options TS7 removed, no version pinned in CI, and no docs stating a version.

No changeset

typescript is a devDependency and doesn't affect the published CLI's runtime tree.

Summary by CodeRabbit

  • Chores

    • Updated TypeScript tooling across the project for improved compatibility and development support.
    • Refined UI package build configuration to produce type declarations more consistently.
    • Improved type-checking coverage for UI build-related files.
    • Updated Node.js type definitions used during UI development.
  • Developer Experience

    • Enhanced reliability and consistency of development and package build workflows.

Moves 11 of 12 workspace packages to TypeScript 7.0.2, the native Go
compiler. Typecheck on apps/api drops from ~2.2s to ~1.1s.

TypeScript 7's npm package no longer ships the JS compiler API — the main
export is just lib/version.cjs, and ts.createProgram / the language service
now live behind typescript/unstable/*. Any tool importing "typescript" and
calling compiler APIs breaks at runtime, which is what gates the two
packages that use such tools.

packages/ui generated its declarations through tsup's dts option, which
runs rollup-plugin-dts against the JS API. tsc emits declarations directly,
so tsup now builds only the JS bundle and tsc emits the .d.ts files. This
also lifts the package off its stale 5.6.3 pin. TypeScript 7 rejects an
inferred rootDir (TS5011), so tsconfig.json sets it explicitly. Declaration
output changes from one bundled index.d.ts to per-file .d.ts; astro check
resolves them cleanly.

apps/web stays on 6.0.3. @astrojs/check@0.9.10 (latest) declares a peer of
typescript ^5.0.0 || ^6.0.0, so TS7 is excluded upstream. astro build works
on 7 — only astro check breaks. Splitting the version within the package
isn't worth it: tsconfig.worker.json covers 4 files while astro check covers
149. Revisit when Astro ships support.

No changeset: typescript is a devDependency and does not affect the
published CLI's runtime tree.

Also splits packages/ui's tsconfig: tsconfig.json now covers src plus
tsup.config.ts (for typecheck and type-aware lint), while a new
tsconfig.build.json carries rootDir for the declaration emit. tsup.config.ts
imports node:fs but sat outside every tsconfig include, so it had no program
and type-aware lint on it failed — a latent issue predating this change,
surfaced because the file is touched here. @types/node added to match the
six other packages already on ^26.1.0.
@zachdunn

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The repository upgrades TypeScript to 7.0.2. The UI package adds Node types and a dedicated declaration build. Its tsup configuration no longer emits declarations.

Changes

TypeScript and UI build updates

Layer / File(s) Summary
Repository TypeScript dependency upgrade
package.json, apps/*/package.json, packages/{billing,comment-config,email,errors,storage,uploads}/package.json
Development dependencies now require TypeScript ^7.0.2.
UI declaration build configuration
packages/ui/package.json, packages/ui/tsconfig.json, packages/ui/tsconfig.build.json, packages/ui/tsup.config.ts
The UI build runs tsup, then runs tsc with a source-only build configuration to emit declarations into dist. Node types are included in the main configuration, and tsup declaration output is disabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit checked the TypeScript trail,
Found version seven in every pail.
The UI bundled bright and clean,
While declarations took a separate scene.
“Hop, hop!” said Bun, “the build is green!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary workspace-wide TypeScript upgrade.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/typescript-7-upgrade-3a545d

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
uploads-api a9ab30c Commit Preview URL

Branch Preview URL
Aug 05 2026, 01:27 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
uploads-auth a9ab30c Commit Preview URL

Branch Preview URL
Aug 05 2026, 01:27 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
uploads-web a9ab30c Commit Preview URL

Branch Preview URL
Aug 05 2026, 01:28 PM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ui/tsconfig.json`:
- Line 18: Update the TypeScript compiler options in the packages/ui tsconfig
configuration to use lib: ["ES2022"] instead of the current ES2021, DOM, and
DOM.Iterable libraries, while preserving the existing include entries and other
settings.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b057762e-5dc9-4608-826b-be7d160a660f

📥 Commits

Reviewing files that changed from the base of the PR and between d3a84c4 and a9ab30c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • apps/api/package.json
  • apps/auth/package.json
  • apps/mcp/package.json
  • package.json
  • packages/billing/package.json
  • packages/comment-config/package.json
  • packages/email/package.json
  • packages/errors/package.json
  • packages/storage/package.json
  • packages/ui/package.json
  • packages/ui/tsconfig.build.json
  • packages/ui/tsconfig.json
  • packages/ui/tsup.config.ts
  • packages/uploads/package.json

Comment thread packages/ui/tsconfig.json
"types": ["node"]
},
"include": ["src"]
"include": ["src", "tsup.config.ts"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Use the required TypeScript library configuration.

Line 18 adds tsup.config.ts to a project that uses ES2021, DOM, and DOM.Iterable libraries. Update this project to use lib: ["ES2022"] without DOM libraries. The TypeScript rule requires this configuration for .ts files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/tsconfig.json` at line 18, Update the TypeScript compiler options
in the packages/ui tsconfig configuration to use lib: ["ES2022"] instead of the
current ES2021, DOM, and DOM.Iterable libraries, while preserving the existing
include entries and other settings.

Source: Coding guidelines

@zachdunn

Copy link
Copy Markdown
Member Author

Declining this one — I think the convention is being applied outside the scope it was written for.

The lib: ["ES2022"] rule in AGENTS.md is stated with its rationale attached:

TypeScript strict, ESM only, lib: ["ES2022"] (no DOM — the Workers types own globals like crypto.subtle.timingSafeEqual).

That reasoning is about Workers runtime code, where the Workers types own the globals and pulling in lib.dom would shadow them. packages/ui is the opposite case: a React component library that renders in the browser and ships DOM/DOM.Iterable deliberately. apps/api, apps/auth, and apps/mcp — the actual Workers — all correctly use lib: ["ES2022"].

I did test the suggestion rather than dismiss it. tsc --noEmit with lib: ["ES2022"] reports 0 errors today, so it looks safe on the surface. But that's incidental: skipLibCheck: true suppresses @types/react's own dependence on lib.dom, and no source file currently happens to reference a DOM global directly (the only document hits in this package are inside CSS comments).

It breaks the moment anyone writes ordinary UI-library code. Adding a single typical function to src/:

export function focusIt(el: HTMLDivElement | null) {
  el?.focus();
}
error TS2812: Property 'focus' does not exist on type 'HTMLDivElement'.
Try changing the 'lib' compiler option to include 'dom'.

A DOM ref is routine in a component library, so this would be a latent trap rather than a hardening.

Worth noting on scope too: this PR is a TypeScript version upgrade and didn't introduce the lib setting. Line 18 only appears in the diff because tsup.config.ts was added to include so the file finally lands in a program and can be typechecked.

@zachdunn
Zach Dunn (zachdunn) merged commit 4e1da5a into main Aug 5, 2026
6 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the claude/typescript-7-upgrade-3a545d branch August 5, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant