mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Add correct options for --lib
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2620,7 +2620,14 @@
|
||||
"category": "Message",
|
||||
"code": 6112
|
||||
},
|
||||
|
||||
"Specify library to be included in the compilation:": {
|
||||
"category": "Message",
|
||||
"code": 6113
|
||||
},
|
||||
"Arguments for library option must be: {0}": {
|
||||
"category": "Error",
|
||||
"code": 6114
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
@@ -2531,7 +2531,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface CommandLineOptionBase {
|
||||
name: string;
|
||||
type: "string" | "number" | "boolean" | "object" | "list" | Map<number>; // a value of a primitive type, or an object literal mapping named values to actual values
|
||||
type: "string" | "number" | "boolean" | "object" | "list" | Map<number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
|
||||
isFilePath?: boolean; // True if option value is a path or fileName
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
@@ -2547,7 +2547,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
|
||||
type: Map<number>; // an object literal mapping named values to actual values
|
||||
type: Map<number | string>; // an object literal mapping named values to actual values
|
||||
error: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user