build: run TypeScript 6 and 7 side by side
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"build": "pnpm -w tsc7 -p tools/build-scripts/tsconfig.json",
|
||||
"dev": "node -e \"console.log('dev not configured')\"",
|
||||
"lint": "node -e \"console.log('lint not configured')\"",
|
||||
"test": "node -e \"console.log('test not configured')\"",
|
||||
"typecheck": "tsc -b",
|
||||
"typecheck": "pnpm -w tsc7 -b tools/build-scripts/tsconfig.json",
|
||||
"build:server": "node ./build-server.mjs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../..",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"composite": true
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const workspaceRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const expectedApiVersion = '6.0.3';
|
||||
const expectedCliVersion = '7.0.2';
|
||||
|
||||
const consumers = [
|
||||
['root', 'package.json'],
|
||||
['game frontend', 'app/game-frontend/package.json'],
|
||||
['gateway frontend', 'app/gateway-frontend/package.json'],
|
||||
];
|
||||
|
||||
for (const [label, packagePath] of consumers) {
|
||||
const requireFromConsumer = createRequire(path.join(workspaceRoot, packagePath));
|
||||
const version = requireFromConsumer('typescript').version;
|
||||
if (version !== expectedApiVersion) {
|
||||
throw new Error(`${label} resolved TypeScript API ${version}; expected ${expectedApiVersion}`);
|
||||
}
|
||||
}
|
||||
|
||||
const nativeTscPath = path.join(workspaceRoot, 'node_modules/@typescript/native/bin/tsc');
|
||||
const nativeResult = spawnSync(process.execPath, [nativeTscPath, '--version'], {
|
||||
cwd: workspaceRoot,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (nativeResult.status !== 0) {
|
||||
throw new Error(nativeResult.stderr || nativeResult.stdout || 'TypeScript 7 tsc failed');
|
||||
}
|
||||
|
||||
const cliVersion = nativeResult.stdout.trim().replace(/^Version\s+/, '');
|
||||
if (cliVersion !== expectedCliVersion) {
|
||||
throw new Error(`native tsc resolved ${cliVersion}; expected ${expectedCliVersion}`);
|
||||
}
|
||||
|
||||
console.log(`TypeScript API ${expectedApiVersion}; native tsc ${expectedCliVersion}`);
|
||||
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test:integration": "vitest run --config vitest.config.ts",
|
||||
"typecheck": "tsc -b"
|
||||
"typecheck": "pnpm -w tsc7 -b tools/integration-tests/tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sammo-ts/common": "workspace:*",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"test": "vitest run --config vitest.config.ts",
|
||||
"typecheck": "tsc -b",
|
||||
"typecheck": "pnpm -w tsc7 -b tools/legacy-db-migration/tsconfig.json",
|
||||
"migrate": "tsx src/cli.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -23,7 +23,7 @@
|
||||
"@types/pg": "^8.21.0",
|
||||
"tsdown": "^0.22.14",
|
||||
"tsx": "^4.23.12",
|
||||
"typescript": "6.0.2",
|
||||
"typescript": "6.0.3",
|
||||
"vitest": "^4.1.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../..",
|
||||
"noEmit": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user