Skip to content

Commit

Permalink
fix(cli): Hide @types/yargs types from types
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RomainMuller committed Jun 18, 2019
1 parent 23a143e commit ae01c15
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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
*/
Expand All @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 || [])) {
Expand All @@ -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 || [])) {
Expand Down

0 comments on commit ae01c15

Please sign in to comment.