mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add correct options for --lib
This commit is contained in:
1 parent
eb82824697
commit
be0592da3b
3 files changed
+58
-8
No files matched your search
@@ -273,12 +273,33 @@ namespace ts {
|
||||
element: {
|
||||
name: "lib",
|
||||
type: {
|
||||
"node": ModuleResolutionKind.NodeJs,
|
||||
"classic": ModuleResolutionKind.Classic,
|
||||
// JavaScript only
|
||||
"es5": "lib.es5.d.ts",
|
||||
"es6": "lib.es6.d.ts",
|
||||
"es7": "lib.es7.d.ts",
|
||||
// Host only
|
||||
"dom": "lib.dom.d.ts",
|
||||
"webworker": "lib.webworker.d.ts",
|
||||
"scripthost": "lib.scripthost.d.ts",
|
||||
// ES6 Or ESNext By-feature options
|
||||
"es6.array": "lib.es6.array.d.ts",
|
||||
"es6.collection": "lib.es6.collection.d.ts",
|
||||
"es6.function": "lib.es6.function.d.ts",
|
||||
"es6.iterable": "lib.es6.iterable.d.ts",
|
||||
"es6.math": "lib.es6.math.d.ts",
|
||||
"es6.number": "lib.es6.number.d.ts",
|
||||
"es6.object": "lib.es6.object.d.ts",
|
||||
"es6.promise": "lib.es6.promise.d.ts",
|
||||
"es6.proxy": "lib.es6.proxy.d.ts",
|
||||
"es6.reflect": "lib.es6.reflect.d.ts",
|
||||
"es6.regexp": "lib.es6.regexp.d.ts",
|
||||
"es6.symbol": "lib.es6.symbol.d.ts",
|
||||
"es6.symbol.wellknown": "lib.es6.symbol.wellknown.d.ts",
|
||||
"es7.array.include": "lib.es7.array.include.d.ts"
|
||||
},
|
||||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
|
||||
error: Diagnostics.Arguments_for_library_option_must_be_Colon_0,
|
||||
},
|
||||
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
|
||||
description: Diagnostics.Specify_library_to_be_included_in_the_compilation_Colon,
|
||||
},
|
||||
{
|
||||
name: "allowUnusedLabels",
|
||||
@@ -402,6 +423,27 @@ namespace ts {
|
||||
return optionNameMapCache;
|
||||
}
|
||||
|
||||
// Cache between the name of commandline which is a custom type and a list of all possible custom types
|
||||
const namesOfCustomTypeMapCache: Map<string[]> = {};
|
||||
|
||||
/* @internal */
|
||||
export function getNamesOfCustomTypeFromCommandLineOptionsOfCustomType(opt: CommandLineOptionOfCustomType): string[] {
|
||||
if (hasProperty(namesOfCustomTypeMapCache, opt.name)) {
|
||||
return namesOfCustomTypeMapCache[opt.name];
|
||||
}
|
||||
|
||||
const type = opt.type;
|
||||
const namesOfType: string[] = [];
|
||||
for (const typeName in type) {
|
||||
if (hasProperty(type, typeName)) {
|
||||
namesOfType.push(typeName);
|
||||
}
|
||||
}
|
||||
|
||||
namesOfCustomTypeMapCache[opt.name] = namesOfType;
|
||||
return namesOfCustomTypeMapCache[opt.name];
|
||||
}
|
||||
|
||||
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
|
||||
const options: CompilerOptions = {};
|
||||
const fileNames: string[] = [];
|
||||
@@ -482,7 +524,8 @@ namespace ts {
|
||||
return map[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(opt.error));
|
||||
const suggestedOption = getNamesOfCustomTypeFromCommandLineOptionsOfCustomType(opt);
|
||||
errors.push(createCompilerDiagnostic(opt.error, suggestedOption ? suggestedOption : undefined));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user