Add a new unittest for command line parsing for --lib

This commit is contained in:
Kanchalai Tanglertsampan
2016-03-15 11:44:33 -07:00
parent c7df7770cd
commit 157b8e7456
5 changed files with 182 additions and 17 deletions

View File

@@ -518,7 +518,7 @@ namespace ts {
}
function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string) {
const map = <Map<number>>opt.type;
const map = opt.type;
const key = (value || "").toLowerCase();
if (hasProperty(map, key)) {
return map[key];
@@ -529,12 +529,15 @@ namespace ts {
}
}
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string): number[] | string[] {
const values = (value || "").split(",");
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string): (number | string)[] {
const values = (value || "").split(",").filter(v => { return v != undefined; });
switch (opt.element.type) {
case "number": return ts.map(values, parseInt);
case "string": return ts.map(values, v => v || "");
default: return ts.map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v));
case "number":
return ts.map(values, parseInt);
case "string":
return ts.map(values, v => v || "");
default:
return ts.map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v)).filter(v => { return v != undefined; });
}
}
}

View File

@@ -2437,6 +2437,7 @@ namespace ts {
allowSyntheticDefaultImports?: boolean;
allowJs?: boolean;
noImplicitUseStrict?: boolean;
lib?: string[];
/* @internal */ stripInternal?: boolean;
// Skip checking lib.d.ts to help speed up tests.
@@ -2446,7 +2447,7 @@ namespace ts {
list?: string[];
[option: string]: string | number | boolean | TsConfigOnlyOptions | string[] | number[];
[option: string]: string | number | boolean | TsConfigOnlyOptions | (string | number)[];
}
export interface TypingOptions {