Skip to content

feat!: support TypeScript 7 in plugin-kit, require typescript 6.x || 7.x#1554

Merged
stipsan merged 2 commits into
mainfrom
cursor/plugin-kit-typescript6-baseline-5eb8
Jul 13, 2026
Merged

feat!: support TypeScript 7 in plugin-kit, require typescript 6.x || 7.x#1554
stipsan merged 2 commits into
mainfrom
cursor/plugin-kit-typescript6-baseline-5eb8

Conversation

@stipsan

@stipsan stipsan commented Jul 13, 2026

Copy link
Copy Markdown
Member

Applies the same fix to @sanity/plugin-kit as sanity-io/pkg-utils#2978: the TypeScript baseline moves to 6/7, and the JS compiler API is loaded from @typescript/typescript6 instead of typescript.

Why

TypeScript 7 (the Go-native compiler) no longer ships the JS compiler API — its npm entry point only exports version/versionMajorMinor. plugin-kit's readTSConfig (used by verify-package/verify-studio to parse tsconfig.json via ts.readConfigFile/ts.parseJsonConfigFileContent/ts.sys) breaks at runtime when a consumer installs typescript@7, which is now latest on npm.

Changes

  • Peer range (breaking): typescript peer moves from 5.8.x || 5.9.x || 6.0.x to 6.x || 7.x. TypeScript 5.x is no longer supported; 7 is not required.
  • Compiler API via @typescript/typescript6: src/util/ts.ts and the ParsedCommandLine type imports in verify-common.ts/validations.ts now use the official @typescript/typescript6 compat package, added as a regular dependency (statically imported, same as pkg-utils@11). The installed typescript peer no longer affects tsconfig parsing and is only used to run tsc --build. @sanity/pkg-utils@11 already ships the same dependency, so it dedupes in consumer trees.
  • plugin-kit init scaffolds typescript at ^6 instead of latest: discovered while smoke-testing — with typescript@7 as latest, freshly scaffolded plugins failed npm install with an ERESOLVE conflict because the scaffolded @typescript-eslint@8 toolchain declares peer typescript ">=4.8.4 <6.1.0". Locked with a comment to unlock once typescript-eslint supports TS 7.
  • Changeset: major for @sanity/plugin-kit.

Verification

  • pnpm format, pnpm lint, pnpm knip, pnpm build, pnpm test run (167 files, 893 tests) all pass, including plugin-kit's init -> verify-package -> tsc -> pkg-utils build integration test.
  • Packed-tarball consumer smoke tests:
    • pnpm consumer with typescript@7.0.2: verify-package parses tsconfig via @typescript/typescript6 and its spawned tsc --build runs the Go-native TS7 compiler; full npm run build passes.
    • npm consumer with typescript@7.0.2: TS7 tsc --build compiles the scaffold directly; verify-package and the full build pass (npm's hoisted .bin/tsc collision with @typescript/old pre-exists for every pkg-utils@11 consumer).
    • Default plugin-kit init scaffold: installs cleanly again with typescript ^6.0.3 (previously failed with ERESOLVE against latest = 7.0.2).
Smoke test log
=== 1) pnpm consumer with typescript 7.0.2 ===
plugin-kit peer typescript: 6.x || 7.x
plugin-kit dependency @typescript/typescript6: ^6.0.2
node_modules/.bin/tsc --version: Version 7.0.2   <-- the Go-native TS7 compiler

--- npx plugin-kit verify-package (tsconfig parsed via @typescript/typescript6; spawned 'tsc --build' is TypeScript 7) ---
[info] All checks ok, running TypeScript compiler.
[info] Running command: tsc --build
[success] No outstanding upgrade issues detected.

--- npm run build (plugin-kit verify-package --silent && pkg-utils build --strict --check --clean) ---
sanity-plugin-ts7-smoke@1.0.0
├─ type: module
└─ exports
   └─ sanity-plugin-ts7-smoke
      ├─ source: ./src/index.ts 573 B
      ├─ import: ./dist/index.js 236 B
      └─ default: ./dist/index.js 236 B

[success] 35ms

=== 2) npm consumer with typescript 7.0.2 ===
direct devDependency typescript: 7.0.2
TS7 native tsc builds the project directly:
Version 7.0.2
tsc --build (7.0.2): OK

--- npx plugin-kit verify-package ---
[info] All checks ok, running TypeScript compiler.
[info] Running command: tsc --build
[success] No outstanding upgrade issues detected.

=== 3) default 'plugin-kit init' scaffold now locks typescript to ^6 ===
scaffolded devDependencies.typescript: ^6.0.3
installed typescript: 6.0.3
(before: init scaffolded 'latest' = 7.0.2 and npm install failed with ERESOLVE, because
 @typescript-eslint/parser@8 declares peer typescript '>=4.8.4 <6.1.0')

--- npm run build ---
[success] 34ms
Open in Web Open in Cursor 

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 56c5673

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sanity/plugin-kit Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Jul 13, 2026 10:56am

Request Review

@stipsan stipsan added the 🤖 bot label Jul 13, 2026 — with Cursor
@stipsan
stipsan marked this pull request as ready for review July 13, 2026 11:11
@stipsan
stipsan requested a review from a team as a code owner July 13, 2026 11:11
@stipsan
stipsan requested review from Copilot and juice49 and removed request for a team July 13, 2026 11:11
@stipsan
stipsan merged commit 19d2b9b into main Jul 13, 2026
15 checks passed
@stipsan
stipsan deleted the cursor/plugin-kit-typescript6-baseline-5eb8 branch July 13, 2026 11:12
@squiggler-app squiggler-app Bot mentioned this pull request Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates @sanity/plugin-kit to work when consumers install typescript@7 by switching tsconfig parsing to the classic JS compiler API provided by @typescript/typescript6, while also updating the peer dependency baseline to TypeScript 6/7 and adjusting plugin-kit init scaffolding away from typescript@latest.

Changes:

  • Switch tsconfig parsing (readTSConfig) from typescript to @typescript/typescript6 to avoid runtime breakage under typescript@7.
  • Update @sanity/plugin-kit peer dependency range from TypeScript 5.x/6.0 to 6.x || 7.x, and add @typescript/typescript6 as a dependency.
  • Lock plugin-kit init scaffolding to TypeScript 6 (instead of latest) to avoid installation conflicts when TS7 is latest.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds lockfile entries for the new @typescript/typescript6 dependency.
packages/@sanity/plugin-kit/src/util/ts.ts Loads the JS compiler API from @typescript/typescript6 for tsconfig parsing.
packages/@sanity/plugin-kit/src/npm/resolveLatestVersions.ts Locks scaffolded TypeScript version away from latest to avoid TS7 incompatibilities.
packages/@sanity/plugin-kit/src/actions/verify/verify-common.ts Updates ParsedCommandLine type import to match @typescript/typescript6.
packages/@sanity/plugin-kit/src/actions/verify/validations.ts Updates ParsedCommandLine type import to match @typescript/typescript6.
packages/@sanity/plugin-kit/package.json Adds @typescript/typescript6 dependency and updates typescript peer range to `6.x
.changeset/plugin-kit-typescript-7-support.md Adds a major changeset documenting the breaking peer range update and TS7 support rationale.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)

packages/@sanity/plugin-kit/src/npm/resolveLatestVersions.ts:15

  • lockedDependencies.typescript is set to ^6, but the scaffolded ESLint toolchain currently has a TypeScript peer of >=4.8.4 <6.1.0 (see pnpm-lock.yaml entry for @typescript-eslint/parser@8.63.0). Also, rangeify() always emits a caret range, which would allow upgrading to 6.1+ and reintroduce peer conflicts. Constrain the selection to 6.0.x and emit a ~6.0.z range for the scaffolded TypeScript version.
  'typescript': '^6',
}

export function resolveLatestVersions(packages: string[]) {
  const versions: Record<string, string> = {}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants