Skip to content

Commit 095d8e2

Browse files
authored
fix(cli): Hide @types/yargs types from types (#2907)
The settings.d.ts file was referencing `yargs`, but in fact only using the `yargs.Arguments` type as a stand-in for a `{ [key: string]: unknown }` alias. Replaced with the more restrictive type so we do not have an exported dependency on `yargs` types. Fixes #2895
1 parent 8f400e7 commit 095d8e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/aws-cdk/lib/settings.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs = require('fs-extra');
22
import os = require('os');
33
import fs_path = require('path');
4-
import yargs = require('yargs');
54
import { Tag } from './api/cxapp/stacks';
65
import { debug, warning } from './logging';
76
import util = require('./util');
@@ -14,6 +13,8 @@ export const USER_DEFAULTS = '~/.cdk.json';
1413

1514
const CONTEXT_KEY = 'context';
1615

16+
export type Arguments = { readonly [name: string]: unknown };
17+
1718
/**
1819
* All sources of settings combined
1920
*/
@@ -33,7 +34,7 @@ export class Configuration {
3334
private projectContext: Settings;
3435
private loaded = false;
3536

36-
constructor(commandLineArguments?: yargs.Arguments) {
37+
constructor(commandLineArguments?: Arguments) {
3738
this.commandLineArguments = commandLineArguments
3839
? Settings.fromCommandLineArguments(commandLineArguments)
3940
: new Settings();
@@ -191,7 +192,7 @@ export class Settings {
191192
* @param argv the received CLI arguments.
192193
* @returns a new Settings object.
193194
*/
194-
public static fromCommandLineArguments(argv: yargs.Arguments): Settings {
195+
public static fromCommandLineArguments(argv: Arguments): Settings {
195196
const context = this.parseStringContextListToObject(argv);
196197
const tags = this.parseStringTagsListToObject(argv);
197198

@@ -220,7 +221,7 @@ export class Settings {
220221
return ret;
221222
}
222223

223-
private static parseStringContextListToObject(argv: yargs.Arguments): any {
224+
private static parseStringContextListToObject(argv: Arguments): any {
224225
const context: any = {};
225226

226227
for (const assignment of ((argv as any).context || [])) {
@@ -238,7 +239,7 @@ export class Settings {
238239
return context;
239240
}
240241

241-
private static parseStringTagsListToObject(argv: yargs.Arguments): Tag[] {
242+
private static parseStringTagsListToObject(argv: Arguments): Tag[] {
242243
const tags: Tag[] = [];
243244

244245
for (const assignment of ((argv as any).tags || [])) {

0 commit comments

Comments
 (0)