Skip to content

Commit 233495f

Browse files
committed
refactor(@angular/cli): adjust type usage for eventual ESM building
Several adjustments to type usage with the goal of support for the future building of the package as ESM. These changes were mainly around the `yargs` package where the ESM types differ from the CommonJS types.
1 parent bd9e4a4 commit 233495f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

packages/angular/cli/src/command-builder/command-module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
import { logging, schema } from '@angular-devkit/core';
1010
import { readFileSync } from 'node:fs';
1111
import * as path from 'node:path';
12-
import yargs, {
12+
import yargs from 'yargs';
13+
import type {
1314
ArgumentsCamelCase,
1415
Argv,
1516
CamelCaseKey,
1617
CommandModule as YargsCommandModule,
17-
} from 'yargs';
18+
// Resolution mode is required due to CamelCaseKey missing from esm types
19+
} from 'yargs' with { 'resolution-mode': 'require' };
1820
import { Parser as yargsParser } from 'yargs/helpers';
1921
import { getAnalyticsUserId } from '../analytics/analytics';
2022
import { AnalyticsCollector } from '../analytics/analytics-collector';

packages/angular/cli/src/command-builder/command-runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function runCommand(args: string[], logger: logging.Logger): Promis
138138
: // Unknown exception, re-throw.
139139
err;
140140
})
141-
.wrap(yargs.terminalWidth())
141+
.wrap(localYargs.terminalWidth())
142142
.parseAsync();
143143

144144
return +(process.exitCode ?? 0);

packages/angular/cli/src/command-builder/utilities/json-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*/
88

99
import { json, strings } from '@angular-devkit/core';
10-
import yargs, { Arguments, Argv, PositionalOptions, Options as YargsOptions } from 'yargs';
10+
import type { Arguments, Argv, PositionalOptions, Options as YargsOptions } from 'yargs';
1111

1212
/**
1313
* An option description.
1414
*/
15-
export interface Option extends yargs.Options {
15+
export interface Option extends YargsOptions {
1616
/**
1717
* The name of the option.
1818
*/

0 commit comments

Comments
 (0)