From 40a91a25951399e26e2738a4803ac28be01b04c7 Mon Sep 17 00:00:00 2001 From: "Craig Macomber (Microsoft)" <42876482+CraigMacomber@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:02:09 +0000 Subject: [PATCH] Test with TypeScript 7 --- .../import-testing/src/test/build.spec.ts | 38 +++++++-- .../typescript-versions-host/package.json | 3 +- pnpm-lock.yaml | 81 +++++++++++++++++++ 3 files changed, 115 insertions(+), 7 deletions(-) diff --git a/examples/utils/import-testing/src/test/build.spec.ts b/examples/utils/import-testing/src/test/build.spec.ts index 7a9a3716e47b..d161b60b4e7b 100644 --- a/examples/utils/import-testing/src/test/build.spec.ts +++ b/examples/utils/import-testing/src/test/build.spec.ts @@ -37,6 +37,27 @@ const typescriptVersions = Object.entries(typescriptHostPackageJson.devDependenc const execFileAsync = promisify(execFile); +function resolveCompilerPath(tscName: string): string { + const compilerDir = path.join(typescriptHostDir, "node_modules", tscName); + const compilerPackageJsonPath = path.join(compilerDir, "package.json"); + const compilerPackageJson = JSON.parse(readFileSync(compilerPackageJsonPath, "utf8")) as { + bin?: string | Record; + }; + const { bin } = compilerPackageJson; + + if (bin === undefined) { + throw new Error(`No executable bin found for ${tscName}`); + } + + const binPath = typeof bin === "string" ? bin : (bin.tsc ?? bin.tsgo); + + if (binPath === undefined) { + throw new Error(`No "tsc" executable bin found in ${tscName}`); + } + + return path.join(compilerDir, binPath); +} + /** * Invokes the provided version of tsc to compile code, validating that it type checks with that version of TypeScript. * @param tscName - The name of the TypeScript compiler package to use. Use the package aliases defined in `@fluid-example/typescript-versions-host/package.json`. @@ -48,16 +69,21 @@ async function compileTest( args: string[], project: string = "./tsconfig.test.json", ): Promise { - const result = execFileAsync( - path.join(typescriptHostDir, "node_modules", tscName, "bin", "tsc"), - ["--project", project, "--noEmit", ...args], - {}, - ); + const compilerPath = resolveCompilerPath(tscName); + const result = execFileAsync(compilerPath, ["--project", project, "--noEmit", ...args], {}); try { await result; } catch (error) { - throw new Error((error as Record).stdout); + const compilerError = error as { + stdout?: string; + stderr?: string; + message?: string; + }; + const details = [compilerError.stdout, compilerError.stderr, compilerError.message] + .filter((x): x is string => x !== undefined && x.length > 0) + .join("\n"); + throw new Error(`Failed to compile with ${tscName}:\n${details}`); } } diff --git a/examples/utils/typescript-versions-host/package.json b/examples/utils/typescript-versions-host/package.json index 466a8313b3db..164e88e37484 100644 --- a/examples/utils/typescript-versions-host/package.json +++ b/examples/utils/typescript-versions-host/package.json @@ -23,7 +23,8 @@ "typescript-5.7": "npm:typescript@~5.7.3", "typescript-5.8": "npm:typescript@~5.8.3", "typescript-5.9": "npm:typescript@~5.9.2", - "typescript-6.0": "npm:typescript@~6.0.3" + "typescript-6.0": "npm:typescript@~6.0.3", + "typescript-7.0": "npm:@typescript/native-preview@7.0.0-dev.20260602.1" }, "typeValidation": { "disabled": true diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99c2dffb885e..7165cbe62ff1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5308,6 +5308,9 @@ importers: typescript-6.0: specifier: npm:typescript@~6.0.3 version: typescript@6.0.3 + typescript-7.0: + specifier: npm:@typescript/native-preview@7.0.0-dev.20260602.1 + version: '@typescript/native-preview@7.0.0-dev.20260602.1' examples/utils/webpack-fluid-loader: dependencies: @@ -20465,6 +20468,53 @@ packages: resolution: {integrity: sha512-KiROIzYdEV85YygXw6BI/Dx4fnBlFQu6Mq4QE4MOH9fFnhohw6wX/OAvDY2/C+ut0I3RSPKenvZJIVYqJNkhEw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript/native-preview-darwin-arm64@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-eSPHtC/iz2jp6H4qVXg2f8C03/dbtZCBVTNg6v8iajGRgD/V23kcOArVk4IQAR0VyqKRCkzQK+TLqKGwrQxP1Q==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/native-preview-darwin-x64@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-tw/714Iw8hsleZowmqxaKrBr1TSAuJU99vEXBjVcBQTW9mChWSt7HDSDNaM2Y3XFLiCj8MAJvzf83uP3wIqBtQ==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/native-preview-linux-arm64@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-uh5XGYggWJWf8QVNI4oylUK04pe74WCTq0DqpZx3y/CnnHzVrgWPlEFe+wn2MhknwVAhOtCIYu2F0UKUqHucTA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/native-preview-linux-arm@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-rtGXfkDyUCjASRw/NXhVwOUfDzqSZrfTGBievr71XBcehVlMBZF9DxWVaIfRMKzXfFpVsmD9C+2JnFgDUBrBaQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/native-preview-linux-x64@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-ZKNmZkJCh39uLzHSWC6jeH0d7lTO8ddj1hLm+Gu+4O0maaInZfWLC3xGxME183adMp54tCasCJcZ8XhDgO2NEw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/native-preview-win32-arm64@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-YZ3wcQ/nN0C71CII0P8Sx6jAvh7WX6zwa3wwGXQOOO4SvxQgUu1ijznsOz+Gz3KpjyyXAloGppkA+0JT5BhbmQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/native-preview-win32-x64@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-ENQpKND75VD7WgtGwj1xXpOQKBM0bmjtzC4W9rzxJjInYfbu22VOXnfzEZlb7fmo/EnyZL6QF6P/zx4ojRMX9Q==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + '@typescript/native-preview@7.0.0-dev.20260602.1': + resolution: {integrity: sha512-Gfnju5EahMkyN5Mn9EIFTXabj/yfixdxtLcb1u8fSDWLD9AOflOLO95GuQcyZHPjCNukTE+9uAvjpMKcRNmbXQ==} + engines: {node: '>=16.20.0'} + hasBin: true + '@ungap/structured-clone@1.2.1': resolution: {integrity: sha512-fEzPV3hSkSMltkw152tJKNARhOupqbH96MZWyRjNaYZOMIzbrTeQDG+MTc6Mr2pgzFQzFxAfmhGDNP5QK++2ZA==} deprecated: Potential CWE-502 - Update to 1.3.1 or higher @@ -33532,6 +33582,37 @@ snapshots: '@typescript-eslint/types': 8.56.1 eslint-visitor-keys: 5.0.1 + '@typescript/native-preview-darwin-arm64@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview-darwin-x64@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview-linux-arm64@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview-linux-arm@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview-linux-x64@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview-win32-arm64@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview-win32-x64@7.0.0-dev.20260602.1': + optional: true + + '@typescript/native-preview@7.0.0-dev.20260602.1': + optionalDependencies: + '@typescript/native-preview-darwin-arm64': 7.0.0-dev.20260602.1 + '@typescript/native-preview-darwin-x64': 7.0.0-dev.20260602.1 + '@typescript/native-preview-linux-arm': 7.0.0-dev.20260602.1 + '@typescript/native-preview-linux-arm64': 7.0.0-dev.20260602.1 + '@typescript/native-preview-linux-x64': 7.0.0-dev.20260602.1 + '@typescript/native-preview-win32-arm64': 7.0.0-dev.20260602.1 + '@typescript/native-preview-win32-x64': 7.0.0-dev.20260602.1 + '@ungap/structured-clone@1.2.1': {} '@unrs/resolver-binding-android-arm-eabi@1.11.1':