diff --git a/.changeset/calm-tools-support.md b/.changeset/calm-tools-support.md new file mode 100644 index 0000000..79b4a68 --- /dev/null +++ b/.changeset/calm-tools-support.md @@ -0,0 +1,5 @@ +--- +"@stll/typescript-config": patch +--- + +Support direct TypeScript 7 and split TypeScript 6 compatibility installs. diff --git a/README.md b/README.md index 0c14cea..5233ed1 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,20 @@ newer, and oxlint-tsgolint 7.0.2001 or newer. Pin the current versions from `@stll/typescript-config/toolchain.json`; do not use the deprecated oxlint-tsgolint 0.x line. -TypeScript 6 is compatibility-only. A repository may keep it under the -`typescript` package name only for a command that loads one of the peer -blockers listed in `toolchain.json`. Code that imports the compiler API must -use the manifest's `typescript-compat` package alias instead. The normal -compiler remains TypeScript 7; install it directly or under an alias such as -`@typescript/native`. Remove each compatibility install when its listed -blocker or API consumer accepts TypeScript 7. +`toolchain.json` defines two supported TypeScript install layouts: + +- `direct` installs TypeScript 7 as `typescript` and runs the normal `tsc` + binary. Prefer this when every framework and compiler-API consumer supports + TypeScript 7. +- `split-compatibility` keeps TypeScript 6 as `typescript` for incompatible + compiler-API consumers, then installs TypeScript 7 as `@typescript/native` + and invokes that binary for typechecking. + +TypeScript 6 is compatibility-only. Use the split layout only for a command +that loads one of the peer blockers listed in `toolchain.json`, or for code +that imports the TypeScript compiler API. Remove the compatibility install when +the blocker accepts TypeScript 7. The shared config's peer range accepts both +layouts; the compiler and typecheck command in each layout remain TypeScript 7. Use the library TypeScript preset: diff --git a/bun.lock b/bun.lock index aab0203..df7677d 100644 --- a/bun.lock +++ b/bun.lock @@ -50,7 +50,7 @@ "name": "@stll/typescript-config", "version": "0.2.0", "peerDependencies": { - "typescript": ">=7.0.2 <8", + "typescript": ">=6.0.3 <8", }, }, }, diff --git a/packages/oxlint-config/src/toolchain-policy.test.ts b/packages/oxlint-config/src/toolchain-policy.test.ts index fcdfd2c..b8b621a 100644 --- a/packages/oxlint-config/src/toolchain-policy.test.ts +++ b/packages/oxlint-config/src/toolchain-policy.test.ts @@ -29,6 +29,23 @@ describe("shared toolchain policy", () => { oxlint: "1.75.0", "oxlint-tsgolint": "7.0.2001", typescript: "7.0.2", + typescriptInstallLayouts: [ + { + compilerPackage: "typescript", + compilerSpecifier: "7.0.2", + type: "direct", + typecheckCommand: "tsc --noEmit", + }, + { + compatibilityPackage: "typescript", + compatibilitySpecifier: "6.0.3", + compilerPackage: "@typescript/native", + compilerSpecifier: "npm:typescript@7.0.2", + type: "split-compatibility", + typecheckCommand: + "node ./node_modules/@typescript/native/bin/tsc --noEmit", + }, + ], typescript6Compatibility: { apiConsumers: ["TypeScript compiler API"], packageAlias: "typescript-compat", @@ -38,13 +55,8 @@ describe("shared toolchain policy", () => { }); }); - test("rejects pre-TS7 compiler and tsgolint consumers", async () => { - const oxlintPackage = await readJson( - "packages/oxlint-config/package.json", - ); - const typescriptPackage = await readJson( - "packages/typescript-config/package.json", - ); + test("rejects pre-TS7 tsgolint consumers", async () => { + const oxlintPackage = await readJson("packages/oxlint-config/package.json"); expect(oxlintPackage).toEqual( expect.objectContaining({ @@ -54,11 +66,17 @@ describe("shared toolchain policy", () => { }, }), ); + }); + + test("supports both TypeScript install layouts", async () => { + const typescriptPackage = await readJson( + "packages/typescript-config/package.json", + ); expect(typescriptPackage).toEqual( expect.objectContaining({ peerDependencies: { - typescript: ">=7.0.2 <8", + typescript: ">=6.0.3 <8", }, }), ); diff --git a/packages/typescript-config/package.json b/packages/typescript-config/package.json index 9b183fd..abee228 100644 --- a/packages/typescript-config/package.json +++ b/packages/typescript-config/package.json @@ -19,10 +19,10 @@ "./bun.json": "./bun.json", "./toolchain.json": "./toolchain.json" }, - "peerDependencies": { - "typescript": ">=7.0.2 <8" - }, "publishConfig": { "access": "public" + }, + "peerDependencies": { + "typescript": ">=6.0.3 <8" } } diff --git a/packages/typescript-config/toolchain.json b/packages/typescript-config/toolchain.json index 6c2fd31..6662821 100644 --- a/packages/typescript-config/toolchain.json +++ b/packages/typescript-config/toolchain.json @@ -2,6 +2,22 @@ "typescript": "7.0.2", "oxlint": "1.75.0", "oxlint-tsgolint": "7.0.2001", + "typescriptInstallLayouts": [ + { + "type": "direct", + "compilerPackage": "typescript", + "compilerSpecifier": "7.0.2", + "typecheckCommand": "tsc --noEmit" + }, + { + "type": "split-compatibility", + "compilerPackage": "@typescript/native", + "compilerSpecifier": "npm:typescript@7.0.2", + "compatibilityPackage": "typescript", + "compatibilitySpecifier": "6.0.3", + "typecheckCommand": "node ./node_modules/@typescript/native/bin/tsc --noEmit" + } + ], "typescript6Compatibility": { "version": "6.0.3", "packageAlias": "typescript-compat",