From 095d8e25d1a493a06b7ee00111f6af72bbf20b22 Mon Sep 17 00:00:00 2001 From: Romain Marcadier-Muller Date: Tue, 18 Jun 2019 17:55:05 +0200 Subject: [PATCH] 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 --- packages/aws-cdk/lib/settings.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/lib/settings.ts b/packages/aws-cdk/lib/settings.ts index 640cc93cf04a7..35706d62b3df6 100644 --- a/packages/aws-cdk/lib/settings.ts +++ b/packages/aws-cdk/lib/settings.ts @@ -1,7 +1,6 @@ import fs = require('fs-extra'); import os = require('os'); import fs_path = require('path'); -import yargs = require('yargs'); import { Tag } from './api/cxapp/stacks'; import { debug, warning } from './logging'; import util = require('./util'); @@ -14,6 +13,8 @@ export const USER_DEFAULTS = '~/.cdk.json'; const CONTEXT_KEY = 'context'; +export type Arguments = { readonly [name: string]: unknown }; + /** * All sources of settings combined */ @@ -33,7 +34,7 @@ export class Configuration { private projectContext: Settings; private loaded = false; - constructor(commandLineArguments?: yargs.Arguments) { + constructor(commandLineArguments?: Arguments) { this.commandLineArguments = commandLineArguments ? Settings.fromCommandLineArguments(commandLineArguments) : new Settings(); @@ -191,7 +192,7 @@ export class Settings { * @param argv the received CLI arguments. * @returns a new Settings object. */ - public static fromCommandLineArguments(argv: yargs.Arguments): Settings { + public static fromCommandLineArguments(argv: Arguments): Settings { const context = this.parseStringContextListToObject(argv); const tags = this.parseStringTagsListToObject(argv); @@ -220,7 +221,7 @@ export class Settings { return ret; } - private static parseStringContextListToObject(argv: yargs.Arguments): any { + private static parseStringContextListToObject(argv: Arguments): any { const context: any = {}; for (const assignment of ((argv as any).context || [])) { @@ -238,7 +239,7 @@ export class Settings { return context; } - private static parseStringTagsListToObject(argv: yargs.Arguments): Tag[] { + private static parseStringTagsListToObject(argv: Arguments): Tag[] { const tags: Tag[] = []; for (const assignment of ((argv as any).tags || [])) {