diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d76c64cf835..1f8a40ab363 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -34,7 +34,6 @@ "open": "^11.0.0", "semver": "^7.7.4", "strip-json-comments": "^5.0.3", - "typescript": "^5.9.3", "update-notifier": "^7.3.1", "uuid": "^13.0.1", "yaml": "^2.8.3", @@ -67,6 +66,7 @@ "@types/yargs-parser": "^21.0.3", "@typescript-eslint/eslint-plugin": "^8.59.1", "@typescript-eslint/parser": "^8.58.0", + "@typescript/native-preview": "^7.0.0-dev.20260421.2", "c8": "^11.0.0", "eslint": "^10.2.1", "eslint-plugin-mocha": "^11.2.0", @@ -74,8 +74,7 @@ "mocha": "^11.7.5", "rimraf": "^6.1.3", "sinon": "^21.1.2", - "source-map-support": "^0.5.21", - "tsc-watch": "^7.2.0" + "source-map-support": "^0.5.21" } }, "node_modules/@actions/core": { @@ -2366,6 +2365,123 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@typescript/native-preview": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview/-/native-preview-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-CmajHI25HpVWE9R1XFoxr+cphJPxoYD3eFioQtAvXYkMFKnLdICMS9pXre9Pybizb75ejRxjKD5/CVG055rEIg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsgo": "bin/tsgo.js" + }, + "optionalDependencies": { + "@typescript/native-preview-darwin-arm64": "7.0.0-dev.20260421.2", + "@typescript/native-preview-darwin-x64": "7.0.0-dev.20260421.2", + "@typescript/native-preview-linux-arm": "7.0.0-dev.20260421.2", + "@typescript/native-preview-linux-arm64": "7.0.0-dev.20260421.2", + "@typescript/native-preview-linux-x64": "7.0.0-dev.20260421.2", + "@typescript/native-preview-win32-arm64": "7.0.0-dev.20260421.2", + "@typescript/native-preview-win32-x64": "7.0.0-dev.20260421.2" + } + }, + "node_modules/@typescript/native-preview-darwin-arm64": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-darwin-arm64/-/native-preview-darwin-arm64-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-fHv1r3ZmVo6zxuAIFmuX3w9QxbcauoG0SsWhmDwm6VmRubLlOJIcmTtlmV3JAb9oOnq8LuzZljzT7Q39fSMQDw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@typescript/native-preview-darwin-x64": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-darwin-x64/-/native-preview-darwin-x64-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-KWTR6xbW9t+JS7D5DQIzo75pqVXVWUxF9PMv/+S6xsnOjCVd6g0ixHcFpFMJMKSUQpGPr8Z5f7b8ks6LHW01jg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@typescript/native-preview-linux-arm": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-arm/-/native-preview-linux-arm-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-BWLQO3nemLDSV5PoE5GPHe1dU9Dth77Kv8/cle9Ujcp4LhPo0KincdPqFH/qKeU/xvW25mgFueflZ1nc4rKuww==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@typescript/native-preview-linux-arm64": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-arm64/-/native-preview-linux-arm64-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-VLMEuml3BhUb+jaL0TXQ4xvVODxJF+RhkI+tBWvlynsJI4khTXEiwWh+wPOJrsfBRYFRMXEu28Odl/HXkYze8w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@typescript/native-preview-linux-x64": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-x64/-/native-preview-linux-x64-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-qUrJWTB5/wv4wnRG0TRXElAxc2kykNiRNyEIEqBbLmzDlrcvAW7RRy8MXoY1ZyTiKGMu14itZ3x9oW6+blFpRw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@typescript/native-preview-win32-arm64": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-win32-arm64/-/native-preview-win32-arm64-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-Rc6NsWlZmCs5YUKVzKgwoBOoRUGsPzct4BDMRX0csD1devLBBc4AbUXWKsJRbpwIAnqMO1ld4sNHEb+wXgfNHQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@typescript/native-preview-win32-x64": { + "version": "7.0.0-dev.20260421.2", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-win32-x64/-/native-preview-win32-x64-7.0.0-dev.20260421.2.tgz", + "integrity": "sha512-GQv1+dya1t6EqF2Cpsb+xoozovdX10JUSf6Kl/8xNkTapzmlHd+uMr+8ku3jIASTxoRGn0Mklgjj3MDKrOTuLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@typespec/ts-http-runtime": { "version": "0.3.2", "license": "MIT", @@ -3201,11 +3317,6 @@ "node": ">= 0.4" } }, - "node_modules/duplexer": { - "version": "0.1.2", - "dev": true, - "license": "MIT" - }, "node_modules/eastasianwidth": { "version": "0.2.0", "dev": true, @@ -3525,20 +3636,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-stream": { - "version": "3.3.4", - "dev": true, - "license": "MIT", - "dependencies": { - "duplexer": "~0.1.1", - "from": "~0", - "map-stream": "~0.1.0", - "pause-stream": "0.0.11", - "split": "0.3", - "stream-combiner": "~0.0.4", - "through": "~2.3.1" - } - }, "node_modules/execa": { "version": "9.6.1", "license": "MIT", @@ -3764,11 +3861,6 @@ "version": "2.1.2", "license": "MIT" }, - "node_modules/from": { - "version": "0.1.7", - "dev": true, - "license": "MIT" - }, "node_modules/function-bind": { "version": "1.1.2", "license": "MIT", @@ -4566,10 +4658,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/map-stream": { - "version": "0.1.0", - "dev": true - }, "node_modules/math-intrinsics": { "version": "1.1.0", "license": "MIT", @@ -4722,11 +4810,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-cleanup": { - "version": "2.1.2", - "dev": true, - "license": "MIT" - }, "node_modules/node-forge": { "version": "1.4.0", "license": "(BSD-3-Clause OR GPL-2.0)", @@ -4918,17 +5001,6 @@ "dev": true, "license": "ISC" }, - "node_modules/pause-stream": { - "version": "0.0.11", - "dev": true, - "license": [ - "MIT", - "Apache2" - ], - "dependencies": { - "through": "~2.3" - } - }, "node_modules/pg-int8": { "version": "1.0.1", "license": "ISC", @@ -5069,20 +5141,6 @@ "node": ">=10" } }, - "node_modules/ps-tree": { - "version": "1.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "event-stream": "=3.3.4" - }, - "bin": { - "ps-tree": "bin/ps-tree.js" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/punycode": { "version": "2.3.1", "dev": true, @@ -5484,25 +5542,6 @@ "source-map": "^0.6.0" } }, - "node_modules/split": { - "version": "0.3.3", - "dev": true, - "license": "MIT", - "dependencies": { - "through": "2" - }, - "engines": { - "node": "*" - } - }, - "node_modules/stream-combiner": { - "version": "0.0.4", - "dev": true, - "license": "MIT", - "dependencies": { - "duplexer": "~0.1.1" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "license": "MIT", @@ -5510,14 +5549,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/string-argv": { - "version": "0.3.2", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.6.19" - } - }, "node_modules/string-width": { "version": "5.1.2", "dev": true, @@ -5798,11 +5829,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/through": { - "version": "2.3.8", - "dev": true, - "license": "MIT" - }, "node_modules/tinyglobby": { "version": "0.2.16", "dev": true, @@ -5836,26 +5862,6 @@ "typescript": ">=4.8.4" } }, - "node_modules/tsc-watch": { - "version": "7.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "cross-spawn": "^7.0.6", - "node-cleanup": "^2.1.2", - "ps-tree": "^1.2.0", - "string-argv": "^0.3.2" - }, - "bin": { - "tsc-watch": "dist/lib/tsc-watch.js" - }, - "engines": { - "node": ">=12.12.0" - }, - "peerDependencies": { - "typescript": "*" - } - }, "node_modules/tslib": { "version": "2.8.1", "license": "0BSD" @@ -5899,7 +5905,9 @@ }, "node_modules/typescript": { "version": "5.9.3", + "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 704ff60024e..dbc04449fc2 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ }, "type": "module", "scripts": { - "build": "tsc -p . && node scripts/write-all-commands.js && node scripts/copy-files.js", - "watch": "tsc-watch --onSuccess \"node scripts/write-all-commands.js\"", + "build": "tsgo -p . && node scripts/write-all-commands.js && node scripts/copy-files.js", + "watch": "node scripts/watch.js", "clean": "rimraf ./dist", "test": "npm run test:version && npm run lint && npm run test:cov", "test:version": "node scripts/check-version.js", @@ -327,7 +327,6 @@ "open": "^11.0.0", "semver": "^7.7.4", "strip-json-comments": "^5.0.3", - "typescript": "^5.9.3", "update-notifier": "^7.3.1", "uuid": "^13.0.1", "yaml": "^2.8.3", @@ -354,6 +353,7 @@ "@types/yargs-parser": "^21.0.3", "@typescript-eslint/eslint-plugin": "^8.59.1", "@typescript-eslint/parser": "^8.58.0", + "@typescript/native-preview": "^7.0.0-dev.20260421.2", "c8": "^11.0.0", "eslint": "^10.2.1", "eslint-plugin-mocha": "^11.2.0", @@ -361,7 +361,6 @@ "mocha": "^11.7.5", "rimraf": "^6.1.3", "sinon": "^21.1.2", - "source-map-support": "^0.5.21", - "tsc-watch": "^7.2.0" + "source-map-support": "^0.5.21" } } diff --git a/scripts/watch.js b/scripts/watch.js new file mode 100644 index 00000000000..5cd5ade16be --- /dev/null +++ b/scripts/watch.js @@ -0,0 +1,26 @@ +import { spawn } from 'node:child_process'; +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const tsgoPath = resolve(__dirname, '..', 'node_modules', '.bin', 'tsgo'); + +const tsgo = spawn(tsgoPath, ['--watch'], { stdio: 'pipe' }); + +tsgo.stdout.on('data', (data) => { + const output = data.toString(); + process.stdout.write(output); + + if (output.includes('Found 0 errors.')) { + const cmd = spawn(process.execPath, [resolve(__dirname, 'write-all-commands.js')], { stdio: 'inherit' }); + cmd.on('error', (err) => console.error('Failed to run write-all-commands:', err)); + } +}); + +tsgo.stderr.on('data', (data) => { + process.stderr.write(data); +}); + +tsgo.on('close', (code) => { + process.exit(code); +}); diff --git a/src/Command.ts b/src/Command.ts index 4727c17c527..723ebf63168 100644 --- a/src/Command.ts +++ b/src/Command.ts @@ -359,7 +359,7 @@ export default abstract class Command { protected handleRejectedODataPromise(res: any): void { /* c8 ignore next 4 */ - if (this.debug && typeof global.it === 'undefined') { + if (this.debug && typeof (global as any).it === 'undefined') { const error = new Error(); cli.error(error.stack).catch(() => undefined); } @@ -404,7 +404,7 @@ export default abstract class Command { protected handleRejectedODataJsonPromise(response: any): void { /* c8 ignore next 4 */ - if (this.debug && typeof global.it === 'undefined') { + if (this.debug && typeof (global as any).it === 'undefined') { const error = new Error(); cli.error(error.stack).catch(() => undefined); } diff --git a/src/utils/zod.ts b/src/utils/zod.ts index f03185dbb0b..168fd7ba17f 100644 --- a/src/utils/zod.ts +++ b/src/utils/zod.ts @@ -1,9 +1,10 @@ import { z } from 'zod'; import { JSONSchema } from 'zod/v4/core'; -import { EnumLike } from 'zod/v4/core/util.cjs'; import { CommandOptionInfo } from '../cli/CommandOptionInfo'; import { CommandOption } from '../Command'; +type EnumLike = Readonly>; + declare module 'zod' { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface ZodType = z.core.$ZodTypeInternals> { @@ -157,5 +158,5 @@ export const zod = { } return null; - }, z.enum(e)) + }, z.enum(e)) as unknown as z.ZodPipe, z.ZodEnum> }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 16eebbd6b5f..660c9cfb60c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,9 @@ "compilerOptions": { "target": "es2020", "module": "esnext", - "moduleResolution": "Node", + "moduleResolution": "bundler", "lib": ["es2020", "dom"], + "types": ["mocha", "node"], "allowSyntheticDefaultImports": true, "sourceMap": true, "outDir": "./dist",