Skip to content

build: Move to TypeScript 7, pnpm 12 and a shared strict policy - #2266

Merged
joshuarli merged 18 commits into
mainfrom
chore/ts7-pnpm12-oxc-modernization
Nov 18, 2026
Merged

joshuarli merged 18 commits into
mainfrom
chore/ts7-pnpm12-oxc-modernization

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Toolkit was on TypeScript 5.9 and pnpm 11, each project had its own type-check settings, and many tests, scripts, Worker and build configs were never type-checked in CI. This moves the workspace to TypeScript 7.0.2 and pnpm 12.18.0, applies one strict tsconfig policy to every maintained TypeScript file, and adds stronger type-aware Oxlint rules. Published package contracts are unchanged.

This single PR supersedes the stacked #2240, #2187, #2238, and #2239: everything those branches carried is here, rebased onto current main (which also carries #2186). #2187's metric alert query filter fix is included as a cherry-pick. It follows that stack's layout: one root tsconfig.base.json that every project extends, no @sentry/mcp-server-tsconfig package, and one root .oxlintrc.json.

Intermediate commits are not individually green; squash-merge.

Changes

  • The root tsconfig.base.json keeps the stack's runtime defaults and adds the rest of the checking policy. Projects set only runtime options such as target, module, lib, types, JSX and emit. The policy enables:
    • strict, noUncheckedIndexedAccess, exactOptionalPropertyTypes, noPropertyAccessFromIndexSignature
    • verbatimModuleSyntax, erasableSyntaxOnly
    • the noUnused* checks
    • skipLibCheck: false
  • Every package's sources, tests, scripts and build configs belong to a program that its typecheck script runs.
  • scripts/tsconfig-policy.test.mjs reads the policy from the root base and guards against:
    • files left uncovered
    • weakened options
    • library-check exceptions without a stated reason
  • Tooling upgrades:
    • Oxlint 1.93 with tsrs-lint (tsrs 7.1.0-beta.tsrs3) for type-aware rules, Oxfmt 0.78, tsdown 0.23
    • Code generators that need the old compiler API now use @typescript/typescript6.
  • New lint rules for the whole repo: promise misuse, exhaustive switches, only-throw-error and related safety rules.
  • Non-test code outside the CLI, including apps/local, now also bans any, !, unnecessary conditions and unsafe any flows.
  • Bugs that stricter types exposed:
    • mcp-cloudflare now rejects incomplete OAuth approval states and empty HMAC signatures.
    • mcp-cloudflare's /api/chat now returns a 500 for a non-Error throw.
    • apps/local's Web Vitals view no longer crashes when a page has no metrics.
    • The CLI's command-api.json regained the fixed query notes it had lost.

Impact

  • pnpm 11 switches itself to 12.18.0 because of the packageManager pin. The first switch adds @pnpm/exe entries to pnpm-lock.yaml; discard them.
  • typecheck is the canonical script. tsc remains as an alias.
  • The quality job in CI builds @sentry/mcp-core and @sentry/logger before lint, because type-aware rules read workspace packages through their built declarations.

Exceptions

  • packages/codemod-cli3to4/tsconfig.json repeats the checking options instead of extending the root, because jssg cannot resolve an extends outside the package. The policy test fails if the copy drifts.
  • 11 programs keep skipLibCheck: true, each with a comment naming the dependency, the diagnostic and when to remove it:
    • ai declarations (under exactOptionalPropertyTypes, and DOM or Node names they reference)
    • @cloudflare/workers-types conflicting with @types/node globals, and urlpattern-polyfill against the workers-types URLPattern global
    • wrangler and miniflare declarations referencing packages they bundle but do not ship
    • unplugin and vite declarations referencing packages they don't ship
    • hono declarations using DOM names in the Node program
  • apps/cli-docs keeps astro check on TypeScript 6 until @astrojs/check supports TypeScript 7.
  • Vitest is pinned to ~5.0.5. Vitest 5.1 needs AsyncLocalStorage.disable(), which workerd lacks. Remove the pin once @cloudflare/vitest-plugin ≥ 1.7.0 is adopted.
  • Type-aware lint runs on tsrs-lint, which tracks the TypeScript 7.1 beta. pnpm run typecheck stays on TypeScript 7.0 and is the type gate. .pnpmfile.cjs drops oxlint's optional oxlint-tsgolint peer, which pnpm 12 would otherwise install unused. tsrs3 is newer than the release-age window, so its packages are in minimumReleaseAgeExclude.

Open questions

  • In mcp-cloudflare's chat-message.tsx, the tool-part state mapping never sees "result" under AI SDK v6. That bug predates this PR and is left as is.

Refs getsentry/junior#2171

via @joshuarli.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 18, 2026 9:50pm UTC
sentry-local Ready Ready Preview Nov 18, 2026 9:50pm UTC

Request Review

Comment on lines 317 to 326
const server = new McpServer(
{
...MCP_SERVER_INFO,
version: getServerVersion(),
},
{
maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS,
instructions: buildServerInstructions(
new Set(registrations.map(({ name }) => name)),
),
...(instructions !== undefined && { instructions }),
},
);

@semgrep-code-getsentry semgrep-code-getsentry Bot Nov 14, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High severity issue identified in your code:

Risk: Affected versions of @modelcontextprotocol/sdk and @modelcontextprotocol/server are vulnerable to Allocation of Resources Without Limits or Throttling. McpServer places no limit on how many array elements and object keys it validates in tool-call arguments. A single unauthenticated HTTP request within the default 4 MiB body limit can exhaust the Node.js heap during validation and crash the server process (denial of service). After upgrading, also set the opt-in maxToolInputElements McpServer option and lower maxRequestBodySize.

Manual Review Advice: A vulnerability from this advisory is reachable if you expose the McpServer over an HTTP transport (Streamable HTTP, SSE, or createMcpHandler) rather than stdio only and it registers tools that accept input, especially arrays or records

Fix: Upgrade this library to at least version 2.3.0 at toolkit/pnpm-lock.yaml:3187.

Reference(s): https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-117803, GHSA-46jr-4wx8-v453

🥳 Fixed in commit ed3902b 🥳

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR doesn't introduce or change this dependency. pnpm-lock.yaml on main has the same entries: @modelcontextprotocol/server 2.0.0 and 2.4.0, and @modelcontextprotocol/sdk 1.32.2. The finding lands on this line only because the PR also edits server.ts.

The 2.0.0 copy, which is older than the 2.3.0 fix, comes only through @mastra/core in apps/docs-mcp. @sentry/mcp-core and @sentry/mcp-cloudflare resolve 2.4.0.

Upgrading the dependency is a separate security fix, so it shouldn't ride along with this tooling migration. I'm leaving the triage (/fp, /ar, or an upgrade) to the code owners rather than marking it here.

@sentry-junior
sentry-junior Bot force-pushed the chore/ts7-pnpm12-oxc-modernization branch from 9724d06 to 527d979 Compare November 14, 2026 17:40
@sentry-junior
sentry-junior Bot changed the base branch from main to josh/tsconfig-mcp-core-strictness November 14, 2026 17:41
JoshuaKGoldberg and others added 16 commits November 18, 2026 12:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rebase onto main pulled in code written without the strict tsconfig
policy and the type-aware lint rules, so the gate failed on it. Fix that
code in place: noUncheckedIndexedAccess index reads, bracket access for
index signatures, exactOptionalPropertyTypes boundaries (widen own option
bags and class fields, omit or spread absent optionals at third-party
boundaries, JSON.stringify now typed as returning string), object-wrapped
flags that control flow narrows to their initial literal, and the lint
rules' fallout (no-unnecessary-condition, no-non-null-assertion,
no-misused-promises). The two abort-reason rejections keep the platform's
verbatim reason behind scoped suppressions.

Co-Authored-By: Inkling 2 Small Free <inkling-2-small-free@users.noreply.github.com>
@joshuarli
joshuarli force-pushed the chore/ts7-pnpm12-oxc-modernization branch from 527d979 to ed3902b Compare November 18, 2026 21:17
@joshuarli
joshuarli changed the base branch from josh/tsconfig-mcp-core-strictness to main November 18, 2026 21:17
The bracket-access conversion replaced env.SENTRY_HANDOFF with env[""], so the handoff code never reached setup.
@joshuarli
joshuarli marked this pull request as ready for review November 18, 2026 21:45
@joshuarli
joshuarli requested a review from a team as a code owner November 18, 2026 21:45
@sentry-junior
sentry-junior Bot requested a review from joshuarli November 18, 2026 21:45
@cursor

cursor Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This PR is too large for Bugbot to review. It changes 22,595 lines and 3,684,439 characters. Split the change into smaller pull requests to get a review.

Replace oxlint-tsgolint with tsrs 7.1.0-beta.tsrs3, the first release on
npm's latest tag. Oxlint prefers tsrs-lint when both backends are on
the path; drop oxlint's optional oxlint-tsgolint peer in .pnpmfile.cjs
because pnpm 12 installs it anyway and nothing would run it.

Full-repo type-aware lint drops from about 8s to about 2s locally with
the same diagnostics. Typecheck stays on TypeScript 7.0, and the
mcp-core, logger and mcp-server-mocks declarations are unchanged.
tsrs3 is newer than the release-age window, so its packages are
excluded explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshuarli
joshuarli enabled auto-merge (squash) November 18, 2026 21:54
@joshuarli
joshuarli merged commit 10bf54e into main Nov 18, 2026
47 of 50 checks passed
@joshuarli
joshuarli deleted the chore/ts7-pnpm12-oxc-modernization branch November 18, 2026 22:00
joshuarli added a commit that referenced this pull request Nov 18, 2026
Follow-ups from the #2266 review.

## Changes

- **mcp-cloudflare regression tests.** An approval cookie with an empty
signature is rejected without reporting an error to Sentry (before #2266
it threw inside `verifySignature` and went through `logError`).
`/api/chat` answers a non-`Error` throw with a JSON 500 and an event ID
(before #2266 Hono returned plain-text "Internal Server Error" and
nothing was logged). Both tests fail against the pre-#2266 code.
- **tsconfig policy.** `typecheckCommandConfigs` throws for a type check
command other than `tsc`, `astro check`, or a `pnpm`/`node` setup step.
Before, such a command added no program, so a package could switch
checkers and drop out of the option checks unnoticed.
- **apps/local `withoutUndefined`.** Accepts only plain records
(`Record<string, unknown>`), since it copies own enumerable string keys.
Class instances and interface-typed values no longer type-check; a test
pins that.
- **CLI metric alert filter.** Removes the `as string | null` guard and
its "null name" test. The command reads `/detectors/`, and Sentry's
`Detector.name` is a non-null `CharField` in every migration, so the
guard covered a response Sentry cannot send. This matches how #2266
already treats issue-alert names.

## Not changed

- The `state.ts` empty-signature guard has no observable effect:
`verifyAndParseState` rejects an empty signature first, and that catch
never logged.
- The Web Vitals `available[0] ?? chosenMetric` fallback is unreachable:
`webVitalPages` drops visits without metrics, so no test can drive it.
- mcp-core's `.d.ts` output can differ between builds only in the order
of union members in inferred types. The types are identical.
- The CLI, MCP and apps/local each keep their own
`omitUndefined`/`withoutUndefined` helper. Merging them into
toolkit-core is a separate change.

## Verification

`pnpm run typecheck`, `pnpm run lint`, `pnpm run test:ci-projects` (194
pass), mcp-cloudflare (469) and apps/local (466) suites pass. CLI alert
tests pass except `alert issues delete > dry-run`, which fails locally
on `main` too because `pnpm exec` adds an `npx -y` prefix to its
expected usage hint.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

3 active and 1 inactive (outdated) deployments
Preview – sentry-local — 00abc03f Deployed Nov 18, 2026 by vercel[bot]
Preview – cli — 00abc03f Deployed Nov 18, 2026 by vercel[bot]
Actions — 00abc03f Deployed Nov 18, 2026 by joshuarli via eval #1969
Preview — cd196aac Deployed Nov 18, 2026 by vercel[bot]
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.

2 participants