mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #7715 from Microsoft/6974AddLibImplementation
6974 add lib implementation
This commit is contained in:
commit
68bdbe04e7
346 files changed
+8786
-2988
No files matched your search
@@ -162,7 +162,6 @@ namespace ts {
|
||||
},
|
||||
{
|
||||
name: "pretty",
|
||||
paramType: Diagnostics.KIND,
|
||||
description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental,
|
||||
type: "boolean"
|
||||
},
|
||||
@@ -332,6 +331,43 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
|
||||
},
|
||||
{
|
||||
name: "lib",
|
||||
type: "list",
|
||||
element: {
|
||||
name: "lib",
|
||||
type: {
|
||||
// JavaScript only
|
||||
"es5": "lib.es5.d.ts",
|
||||
"es6": "lib.es2015.d.ts",
|
||||
"es2015": "lib.es2015.d.ts",
|
||||
"es7": "lib.es2016.d.ts",
|
||||
"es2016": "lib.es2016.d.ts",
|
||||
// Host only
|
||||
"dom": "lib.dom.d.ts",
|
||||
"webworker": "lib.webworker.d.ts",
|
||||
"scripthost": "lib.scripthost.d.ts",
|
||||
// ES2015 Or ESNext By-feature options
|
||||
"es2015.array": "lib.es2015.array.d.ts",
|
||||
"es2015.collection": "lib.es2015.collection.d.ts",
|
||||
"es2015.generator": "lib.es2015.generator.d.ts",
|
||||
"es2015.function": "lib.es2015.function.d.ts",
|
||||
"es2015.iterable": "lib.es2015.iterable.d.ts",
|
||||
"es2015.math": "lib.es2015.math.d.ts",
|
||||
"es2015.number": "lib.es2015.number.d.ts",
|
||||
"es2015.object": "lib.es2015.object.d.ts",
|
||||
"es2015.promise": "lib.es2015.promise.d.ts",
|
||||
"es2015.proxy": "lib.es2015.proxy.d.ts",
|
||||
"es2015.reflect": "lib.es2015.reflect.d.ts",
|
||||
"es2015.regexp": "lib.es2015.regexp.d.ts",
|
||||
"es2015.string": "lib.es2015.string.d.ts",
|
||||
"es2015.symbol": "lib.es2015.symbol.d.ts",
|
||||
"es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts",
|
||||
"es2016.array.include": "lib.es2016.array.include.d.ts"
|
||||
},
|
||||
},
|
||||
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
|
||||
},
|
||||
{
|
||||
name: "strictNullChecks",
|
||||
type: "boolean",
|
||||
@@ -370,6 +406,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let optionNameMapCache: OptionNameMap;
|
||||
|
||||
/* @internal */
|
||||
export function getOptionNameMap(): OptionNameMap {
|
||||
if (optionNameMapCache) {
|
||||
@@ -399,6 +436,32 @@ namespace ts {
|
||||
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) {
|
||||
const key = (value || "").trim().toLowerCase();
|
||||
const map = opt.type;
|
||||
if (hasProperty(map, key)) {
|
||||
return map[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] {
|
||||
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 filter(map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v, errors)), v => !!v);
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
|
||||
const options: CompilerOptions = {};
|
||||
const fileNames: string[] = [];
|
||||
@@ -453,12 +516,12 @@ namespace ts {
|
||||
i++;
|
||||
break;
|
||||
case "list":
|
||||
options[opt.name] = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i]);
|
||||
options[opt.name] = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
|
||||
i++;
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
options[opt.name] = parseCustomTypeOption(<CommandLineOptionOfCustomType>opt, args[i]);
|
||||
options[opt.name] = parseCustomTypeOption(<CommandLineOptionOfCustomType>opt, args[i], errors);
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
@@ -471,29 +534,6 @@ namespace ts {
|
||||
else {
|
||||
fileNames.push(s);
|
||||
}
|
||||
|
||||
function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string) {
|
||||
const key = (value || "").trim().toLowerCase();
|
||||
const map = opt.type;
|
||||
if (hasProperty(map, key)) {
|
||||
return map[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
||||
}
|
||||
}
|
||||
|
||||
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string): (string | number)[] {
|
||||
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 filter(map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v)), v => !!v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user