Using ts.filter instead of just .filter
This commit is contained in:
parent
95b43dac29
commit
4d915e59d9
|
@ -530,14 +530,14 @@ namespace ts {
|
|||
}
|
||||
|
||||
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string): (number | string)[] {
|
||||
const values = (value || "").split(",").filter(v => { return v != undefined; });
|
||||
const values = (value.trim() || "").split(",");
|
||||
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)).filter(v => { return v != undefined; });
|
||||
return ts.filter(ts.map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v)), v => !!v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -793,6 +793,6 @@ namespace ts {
|
|||
}
|
||||
|
||||
function convertJsonOptionOfListType(option: CommandLineOptionOfListType, values: any[], basePath: string, errors: Diagnostic[]): any[] {
|
||||
return ts.map(values, v => convertJsonOption(option.element, v, basePath, errors)).filter(v => { return v != undefined; });
|
||||
return ts.filter(ts.map(values, v => convertJsonOption(option.element, v, basePath, errors)), v => !!v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,26 @@ namespace ts {
|
|||
});
|
||||
});
|
||||
|
||||
it("Parse incorrect form of library flags with trailing white-space ", () => {
|
||||
// --lib es5, es7 0.ts
|
||||
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "",
|
||||
category: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.category,
|
||||
code: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["es7", "0.ts"],
|
||||
options: {
|
||||
lib: ["lib.es5.d.ts"]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse multiple compiler flags with input files at the end", () => {
|
||||
// --lib es5,es6.symbol.wellknown --target es5 0.ts
|
||||
assertParseResult(["--lib", "es5,es6.symbol.wellknown", "--target", "es5", "0.ts"],
|
||||
|
|
Loading…
Reference in a new issue