feat!: support TypeScript 7 in plugin-kit, require typescript 6.x || 7.x#1554
Conversation
🦋 Changeset detectedLatest commit: 56c5673 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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) fromtypescriptto@typescript/typescript6to avoid runtime breakage undertypescript@7. - Update
@sanity/plugin-kitpeer dependency range from TypeScript 5.x/6.0 to6.x || 7.x, and add@typescript/typescript6as a dependency. - Lock
plugin-kit initscaffolding to TypeScript 6 (instead oflatest) to avoid installation conflicts when TS7 islatest.
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.typescriptis 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.zrange 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.
Applies the same fix to
@sanity/plugin-kitas sanity-io/pkg-utils#2978: the TypeScript baseline moves to 6/7, and the JS compiler API is loaded from@typescript/typescript6instead oftypescript.Why
TypeScript 7 (the Go-native compiler) no longer ships the JS compiler API — its npm entry point only exports
version/versionMajorMinor. plugin-kit'sreadTSConfig(used byverify-package/verify-studioto parsetsconfig.jsonviats.readConfigFile/ts.parseJsonConfigFileContent/ts.sys) breaks at runtime when a consumer installstypescript@7, which is nowlateston npm.Changes
typescriptpeer moves from5.8.x || 5.9.x || 6.0.xto6.x || 7.x. TypeScript 5.x is no longer supported; 7 is not required.@typescript/typescript6:src/util/ts.tsand theParsedCommandLinetype imports inverify-common.ts/validations.tsnow use the official@typescript/typescript6compat package, added as a regular dependency (statically imported, same as pkg-utils@11). The installedtypescriptpeer no longer affects tsconfig parsing and is only used to runtsc --build.@sanity/pkg-utils@11already ships the same dependency, so it dedupes in consumer trees.plugin-kit initscaffoldstypescriptat^6instead oflatest: discovered while smoke-testing — withtypescript@7aslatest, freshly scaffolded plugins failednpm installwith anERESOLVEconflict because the scaffolded@typescript-eslint@8 toolchain declares peertypescript ">=4.8.4 <6.1.0". Locked with a comment to unlock once typescript-eslint supports TS 7.@sanity/plugin-kit.Verification
pnpm format,pnpm lint,pnpm knip,pnpm build,pnpm test run(167 files, 893 tests) all pass, including plugin-kit'sinit -> verify-package -> tsc -> pkg-utils buildintegration test.typescript@7.0.2:verify-packageparses tsconfig via@typescript/typescript6and its spawnedtsc --buildruns the Go-native TS7 compiler; fullnpm run buildpasses.typescript@7.0.2: TS7tsc --buildcompiles the scaffold directly;verify-packageand the full build pass (npm's hoisted.bin/tsccollision with@typescript/oldpre-exists for every pkg-utils@11 consumer).plugin-kit initscaffold: installs cleanly again withtypescript ^6.0.3(previously failed withERESOLVEagainstlatest= 7.0.2).Smoke test log