From 8eebbd8e1bdd5c6fc89295f8777701e495ced5c7 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:26:32 -0800 Subject: [PATCH 1/5] Export executeCommandLine from services for public API --- src/executeCommandLine/executeCommandLine.ts | 7 ++++++- src/typescript/_namespaces/ts.ts | 1 + src/typescript/tsconfig.json | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 16d02310b5eb7..8de28c6aa2d3f 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -85,6 +85,7 @@ import { validateLocaleAndSetLanguage, version, WatchCompilerHost, + WatchOfConfigFile, WatchOptions, } from "./_namespaces/ts"; @@ -94,6 +95,7 @@ interface Statistic { type: StatisticType; } +/** @internal */ export enum StatisticType { time, count, @@ -730,6 +732,7 @@ function executeCommandLineWorker( } } +/** @internal */ export function isBuild(commandLineArgs: readonly string[]) { if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === CharacterCodes.minus) { const firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); @@ -738,12 +741,14 @@ export function isBuild(commandLineArgs: readonly string[]) { return false; } +/** @internal */ export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; +/** @internal */ export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[], -) { +): void | SolutionBuilder | WatchOfConfigFile { if (isBuild(commandLineArgs)) { const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs.slice(1)); if (buildOptions.generateCpuProfile && system.enableCPUProfiler) { diff --git a/src/typescript/_namespaces/ts.ts b/src/typescript/_namespaces/ts.ts index 3060a64378787..f105a6c4098db 100644 --- a/src/typescript/_namespaces/ts.ts +++ b/src/typescript/_namespaces/ts.ts @@ -4,5 +4,6 @@ export * from "../../compiler/_namespaces/ts"; export * from "../../jsTyping/_namespaces/ts"; export * from "../../services/_namespaces/ts"; export * from "../../server/_namespaces/ts"; +export * from "../../executeCommandLine/_namespaces/ts"; import * as server from "./ts.server"; export { server }; diff --git a/src/typescript/tsconfig.json b/src/typescript/tsconfig.json index 20b8306af53eb..8aa4380d6d726 100644 --- a/src/typescript/tsconfig.json +++ b/src/typescript/tsconfig.json @@ -6,7 +6,8 @@ { "path": "../compiler" }, { "path": "../jsTyping" }, { "path": "../services" }, - { "path": "../server" } + { "path": "../server" }, + { "path": "../executeCommandLine" } ], "include": ["**/*"] } From 5f3897167c234216387f4d5cfc9c8d89915a7fff Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:19:00 -0700 Subject: [PATCH 2/5] Export --- src/executeCommandLine/executeCommandLine.ts | 11 ++++++++++- tests/baselines/reference/api/typescript.d.ts | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 8de28c6aa2d3f..913e675d1bd1f 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -741,9 +741,18 @@ export function isBuild(commandLineArgs: readonly string[]) { return false; } -/** @internal */ export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; +export function executeCommandLine( + system: System, + cb: ExecuteCommandLineCallbacks, + commandLineArgs: readonly string[], +): void; /** @internal */ +export function executeCommandLine( + system: System, + cb: ExecuteCommandLineCallbacks, + commandLineArgs: readonly string[], +): void | SolutionBuilder | WatchOfConfigFile; export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 7f7bf51496508..d93514c8e36b7 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -11220,5 +11220,7 @@ declare namespace ts { * @param compilerOptions Optional compiler options. */ function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; + function executeCommandLine(system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[]): void; + type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; } export = ts; From 53b1ec5f39073d854bc8d28a9fd34ac3ce01162e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:22:05 -0700 Subject: [PATCH 3/5] fix compile --- src/executeCommandLine/executeCommandLine.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 913e675d1bd1f..9d0528e92548b 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -742,17 +742,17 @@ export function isBuild(commandLineArgs: readonly string[]) { } export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; +/** @internal */ export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[], -): void; -/** @internal */ +): void | SolutionBuilder | WatchOfConfigFile; export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[], -): void | SolutionBuilder | WatchOfConfigFile; +): void; export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, From 3420a71f4d69681279fd24a0945374997a726310 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:55:44 -0700 Subject: [PATCH 4/5] Move executeCommandLine to compiler --- src/compiler/_namespaces/ts.ts | 1 + .../executeCommandLine.ts | 2 +- src/executeCommandLine/_namespaces/ts.ts | 4 ---- src/executeCommandLine/tsconfig.json | 11 ----------- src/testRunner/_namespaces/ts.ts | 1 - src/testRunner/tsconfig.json | 1 - src/tsc/_namespaces/ts.ts | 1 - src/tsc/tsconfig.json | 3 +-- src/tsconfig.json | 1 - src/typescript/_namespaces/ts.ts | 1 - src/typescript/tsconfig.json | 3 +-- tests/baselines/reference/api/typescript.d.ts | 4 ++-- 12 files changed, 6 insertions(+), 27 deletions(-) rename src/{executeCommandLine => compiler}/executeCommandLine.ts (97%) delete mode 100644 src/executeCommandLine/_namespaces/ts.ts delete mode 100644 src/executeCommandLine/tsconfig.json diff --git a/src/compiler/_namespaces/ts.ts b/src/compiler/_namespaces/ts.ts index 1ce7091080e7a..e5c3db7415dd4 100644 --- a/src/compiler/_namespaces/ts.ts +++ b/src/compiler/_namespaces/ts.ts @@ -70,6 +70,7 @@ export * from "../watch"; export * from "../watchPublic"; export * from "../tsbuild"; export * from "../tsbuildPublic"; +export * from "../executeCommandLine"; import * as moduleSpecifiers from "./ts.moduleSpecifiers"; export { moduleSpecifiers }; import * as performance from "./ts.performance"; diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/compiler/executeCommandLine.ts similarity index 97% rename from src/executeCommandLine/executeCommandLine.ts rename to src/compiler/executeCommandLine.ts index 9d0528e92548b..97df6358a3dd8 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/compiler/executeCommandLine.ts @@ -1,4 +1,3 @@ -import * as performance from "../compiler/performance"; import { arrayFrom, BuilderProgram, @@ -88,6 +87,7 @@ import { WatchOfConfigFile, WatchOptions, } from "./_namespaces/ts"; +import * as performance from "./performance"; interface Statistic { name: string; diff --git a/src/executeCommandLine/_namespaces/ts.ts b/src/executeCommandLine/_namespaces/ts.ts deleted file mode 100644 index 488d183df4a38..0000000000000 --- a/src/executeCommandLine/_namespaces/ts.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* Generated file to emulate the ts namespace. */ - -export * from "../../compiler/_namespaces/ts"; -export * from "../executeCommandLine"; diff --git a/src/executeCommandLine/tsconfig.json b/src/executeCommandLine/tsconfig.json deleted file mode 100644 index c988aed5d19c3..0000000000000 --- a/src/executeCommandLine/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig-base", - "compilerOptions": { - }, - - "references": [ - { "path": "../compiler" } - ], - - "include": ["**/*"] -} diff --git a/src/testRunner/_namespaces/ts.ts b/src/testRunner/_namespaces/ts.ts index 18d1bb33fc953..27efc73b10f55 100644 --- a/src/testRunner/_namespaces/ts.ts +++ b/src/testRunner/_namespaces/ts.ts @@ -1,7 +1,6 @@ /* Generated file to emulate the ts namespace. */ export * from "../../compiler/_namespaces/ts"; -export * from "../../executeCommandLine/_namespaces/ts"; export * from "../../services/_namespaces/ts"; export * from "../../jsTyping/_namespaces/ts"; export * from "../../server/_namespaces/ts"; diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 29d2f351b62cf..10bd1d9ef6807 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -9,7 +9,6 @@ }, "references": [ { "path": "../compiler" }, - { "path": "../executeCommandLine" }, { "path": "../services" }, { "path": "../jsTyping" }, { "path": "../server" }, diff --git a/src/tsc/_namespaces/ts.ts b/src/tsc/_namespaces/ts.ts index 8e361ae718461..b9fd7c710ab69 100644 --- a/src/tsc/_namespaces/ts.ts +++ b/src/tsc/_namespaces/ts.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the ts namespace. */ export * from "../../compiler/_namespaces/ts"; -export * from "../../executeCommandLine/_namespaces/ts"; diff --git a/src/tsc/tsconfig.json b/src/tsc/tsconfig.json index 21e193ad5d70c..e0e98fac65db6 100644 --- a/src/tsc/tsconfig.json +++ b/src/tsc/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { }, "references": [ - { "path": "../compiler" }, - { "path": "../executeCommandLine" } + { "path": "../compiler" } ], "include": ["**/*"] } diff --git a/src/tsconfig.json b/src/tsconfig.json index c585d3480f266..0e422305f9d4d 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -5,7 +5,6 @@ { "path": "./cancellationToken" }, { "path": "./compiler" }, { "path": "./deprecatedCompat" }, - { "path": "./executeCommandLine" }, { "path": "./harness" }, { "path": "./jsTyping" }, { "path": "./server" }, diff --git a/src/typescript/_namespaces/ts.ts b/src/typescript/_namespaces/ts.ts index f105a6c4098db..3060a64378787 100644 --- a/src/typescript/_namespaces/ts.ts +++ b/src/typescript/_namespaces/ts.ts @@ -4,6 +4,5 @@ export * from "../../compiler/_namespaces/ts"; export * from "../../jsTyping/_namespaces/ts"; export * from "../../services/_namespaces/ts"; export * from "../../server/_namespaces/ts"; -export * from "../../executeCommandLine/_namespaces/ts"; import * as server from "./ts.server"; export { server }; diff --git a/src/typescript/tsconfig.json b/src/typescript/tsconfig.json index 8aa4380d6d726..20b8306af53eb 100644 --- a/src/typescript/tsconfig.json +++ b/src/typescript/tsconfig.json @@ -6,8 +6,7 @@ { "path": "../compiler" }, { "path": "../jsTyping" }, { "path": "../services" }, - { "path": "../server" }, - { "path": "../executeCommandLine" } + { "path": "../server" } ], "include": ["**/*"] } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d93514c8e36b7..6a26a1bc99c85 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -9821,6 +9821,8 @@ declare namespace ts { emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } type InvalidatedProject = UpdateOutputFileStampsProject | BuildInvalidedProject; + function executeCommandLine(system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[]): void; + type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the @@ -11220,7 +11222,5 @@ declare namespace ts { * @param compilerOptions Optional compiler options. */ function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; - function executeCommandLine(system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[]): void; - type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; } export = ts; From def150a21da0c0de7fa90818ce98c52d63c30ebd Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 3 Apr 2024 11:33:09 -0700 Subject: [PATCH 5/5] Unexport --- src/compiler/executeCommandLine.ts | 11 +---------- tests/baselines/reference/api/typescript.d.ts | 2 -- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/compiler/executeCommandLine.ts b/src/compiler/executeCommandLine.ts index 97df6358a3dd8..ed5c1836c9bbb 100644 --- a/src/compiler/executeCommandLine.ts +++ b/src/compiler/executeCommandLine.ts @@ -741,18 +741,9 @@ export function isBuild(commandLineArgs: readonly string[]) { return false; } +/** @internal */ export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; /** @internal */ -export function executeCommandLine( - system: System, - cb: ExecuteCommandLineCallbacks, - commandLineArgs: readonly string[], -): void | SolutionBuilder | WatchOfConfigFile; -export function executeCommandLine( - system: System, - cb: ExecuteCommandLineCallbacks, - commandLineArgs: readonly string[], -): void; export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6a26a1bc99c85..7f7bf51496508 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -9821,8 +9821,6 @@ declare namespace ts { emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } type InvalidatedProject = UpdateOutputFileStampsProject | BuildInvalidedProject; - function executeCommandLine(system: System, cb: ExecuteCommandLineCallbacks, commandLineArgs: readonly string[]): void; - type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the