From a69000407c7c28c6eef1d0572f32836d76504944 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 28 Jun 2022 10:51:29 +0000 Subject: [PATCH] refactor: clean up old ansi-colors castings This has been fixed in https://github.com/doowb/ansi-colors/pull/44 --- packages/angular/cli/src/utilities/color.ts | 3 +-- packages/angular_devkit/architect_cli/bin/architect.ts | 3 +-- packages/angular_devkit/benchmark/src/main.ts | 3 +-- packages/angular_devkit/build_angular/src/utils/color.ts | 3 +-- packages/angular_devkit/schematics_cli/bin/schematics.ts | 3 +-- tests/legacy-cli/e2e/utils/process.ts | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/angular/cli/src/utilities/color.ts b/packages/angular/cli/src/utilities/color.ts index 8ddcadf3d1..0a93840c05 100644 --- a/packages/angular/cli/src/utilities/color.ts +++ b/packages/angular/cli/src/utilities/color.ts @@ -45,8 +45,7 @@ export function removeColor(text: string): string { } // Create a separate instance to prevent unintended global changes to the color configuration -// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 -const colors = (ansiColors as AnsiColors & { create: () => AnsiColors }).create(); +const colors = ansiColors.create(); colors.enabled = supportColor(); export { colors }; diff --git a/packages/angular_devkit/architect_cli/bin/architect.ts b/packages/angular_devkit/architect_cli/bin/architect.ts index 341757e9f9..cbc5f4ca9a 100644 --- a/packages/angular_devkit/architect_cli/bin/architect.ts +++ b/packages/angular_devkit/architect_cli/bin/architect.ts @@ -71,8 +71,7 @@ interface BarInfo { } // Create a separate instance to prevent unintended global changes to the color configuration -// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 -const colors = (ansiColors as typeof ansiColors & { create: () => typeof ansiColors }).create(); +const colors = ansiColors.create(); async function _executeTarget( parentLogger: logging.Logger, diff --git a/packages/angular_devkit/benchmark/src/main.ts b/packages/angular_devkit/benchmark/src/main.ts index 2c5d52872a..390d0799a3 100644 --- a/packages/angular_devkit/benchmark/src/main.ts +++ b/packages/angular_devkit/benchmark/src/main.ts @@ -111,8 +111,7 @@ export async function main({ ); // Create a separate instance to prevent unintended global changes to the color configuration - // Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 - const colors = (ansiColors as typeof ansiColors & { create: () => typeof ansiColors }).create(); + const colors = ansiColors.create(); // Log to console. logger.pipe(filter((entry) => entry.level != 'debug' || argv['verbose'])).subscribe((entry) => { diff --git a/packages/angular_devkit/build_angular/src/utils/color.ts b/packages/angular_devkit/build_angular/src/utils/color.ts index 8ddcadf3d1..0a93840c05 100644 --- a/packages/angular_devkit/build_angular/src/utils/color.ts +++ b/packages/angular_devkit/build_angular/src/utils/color.ts @@ -45,8 +45,7 @@ export function removeColor(text: string): string { } // Create a separate instance to prevent unintended global changes to the color configuration -// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 -const colors = (ansiColors as AnsiColors & { create: () => AnsiColors }).create(); +const colors = ansiColors.create(); colors.enabled = supportColor(); export { colors }; diff --git a/packages/angular_devkit/schematics_cli/bin/schematics.ts b/packages/angular_devkit/schematics_cli/bin/schematics.ts index 79e0bd9812..af29ca1188 100644 --- a/packages/angular_devkit/schematics_cli/bin/schematics.ts +++ b/packages/angular_devkit/schematics_cli/bin/schematics.ts @@ -117,8 +117,7 @@ export async function main({ const { cliOptions, schematicOptions, _ } = parseArgs(args); // Create a separate instance to prevent unintended global changes to the color configuration - // Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 - const colors = (ansiColors as typeof ansiColors & { create: () => typeof ansiColors }).create(); + const colors = ansiColors.create(); /** Create the DevKit Logger used through the CLI. */ const logger = createConsoleLogger(!!cliOptions.verbose, stdout, stderr, { diff --git a/tests/legacy-cli/e2e/utils/process.ts b/tests/legacy-cli/e2e/utils/process.ts index c302cd80bd..88dcce6353 100644 --- a/tests/legacy-cli/e2e/utils/process.ts +++ b/tests/legacy-cli/e2e/utils/process.ts @@ -27,8 +27,7 @@ export type ProcessOutput = { function _exec(options: ExecOptions, cmd: string, args: string[]): Promise { // Create a separate instance to prevent unintended global changes to the color configuration - // Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 - const colors = (ansiColors as typeof ansiColors & { create: () => typeof ansiColors }).create(); + const colors = ansiColors.create(); let stdout = ''; let stderr = '';