-
Notifications
You must be signed in to change notification settings - Fork 12.8k
6974 Add compiler flag "--lib" #7452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8e5606e
44aed7b
cbec78e
73534a4
00d619d
1609c31
eb30193
3b15eb0
2f43778
41e5b24
067fa12
9fa06fd
5200bf1
8616370
16104a2
f19bd4c
005271e
80f6920
37a7998
69e5045
b461ab8
08f1a77
4684313
6043a97
1704059
779ffe8
8e902c2
c33a7ac
fc42621
70f6969
8e20680
3839898
c1290c1
77639de
b41009a
23cb32e
499b338
2d2bf11
4c89068
5509b48
3f5d374
f052835
92e8f02
a3741e0
e672e5a
1e29d9d
e3dc816
22d5803
23151a8
5f06a4e
05fe71c
e5bbdec
8167317
fbb80ee
eed5020
3aabcda
7d31428
0f7732f
b053f11
812f858
d09c680
94a4beb
7083900
a42ac70
303fa9c
ad969e3
24b9c2f
62e4705
8b8b254
bad10e5
67fa6cc
1e732c5
27d308d
f93cc40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(","); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So as I mentioned, can you be more tolerant of whitespace around commas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it is handling in |
||
switch (opt.element.type) { | ||
case "number": | ||
return ts.map(values, parseInt); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually never even use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you mean by " should the necessarily be only integers?" |
||
case "string": | ||
return ts.map(values, v => v || ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would you have |
||
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); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not think we need to special case this one. we already have rootDirs that is a list and we special case it. we should just handle a
list
type as a valid commandline option type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a semi-working example of what i mean in https://github.com/Microsoft/TypeScript/compare/listOptionParsing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your approach. Should I try to cherry pick them in here?