Skip to content

Commit f3d3661

Browse files
committed
Merge branch 'init' of https://github.com/tinganho/TypeScript into tinganho-init
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/types.ts
2 parents 1381544 + 1670ce9 commit f3d3661

8 files changed

Lines changed: 211 additions & 80 deletions

File tree

src/compiler/commandLineParser.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ namespace ts {
3030
type: "boolean",
3131
description: Diagnostics.Print_this_message,
3232
},
33+
{
34+
name: "init",
35+
type: "boolean",
36+
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
37+
},
3338
{
3439
name: "inlineSourceMap",
3540
type: "boolean",
@@ -237,19 +242,36 @@ namespace ts {
237242
}
238243
];
239244

240-
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
241-
let options: CompilerOptions = {};
242-
let fileNames: string[] = [];
243-
let errors: Diagnostic[] = [];
244-
let shortOptionNames: Map<string> = {};
245-
let optionNameMap: Map<CommandLineOption> = {};
245+
export interface OptionNameMap {
246+
optionNameMap: Map<CommandLineOption>;
247+
shortOptionNames: Map<string>;
248+
}
249+
250+
let optionNameMapCache: OptionNameMap;
251+
export function getOptionNameMap(): OptionNameMap {
252+
if (optionNameMapCache) {
253+
return optionNameMapCache;
254+
}
246255

256+
let optionNameMap: Map<CommandLineOption> = {};
257+
let shortOptionNames: Map<string> = {};
247258
forEach(optionDeclarations, option => {
248259
optionNameMap[option.name.toLowerCase()] = option;
249260
if (option.shortName) {
250261
shortOptionNames[option.shortName] = option.name;
251262
}
252263
});
264+
265+
optionNameMapCache = { optionNameMap, shortOptionNames };
266+
return optionNameMapCache;
267+
}
268+
269+
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
270+
let options: CompilerOptions = {};
271+
let fileNames: string[] = [];
272+
let errors: Diagnostic[] = [];
273+
let { optionNameMap, shortOptionNames } = getOptionNameMap();
274+
253275
parseStrings(commandLine);
254276
return {
255277
options,

src/compiler/core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,14 @@ namespace ts {
287287
return <T>result;
288288
}
289289

290-
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
291-
let result: Map<T> = {};
290+
export function extend<T1, T2>(first: Map<T1>, second: Map<T2>): Map<T1 & T2> {
291+
let result: Map<T1 & T2> = {};
292292
for (let id in first) {
293-
result[id] = first[id];
293+
(result as any)[id] = first[id];
294294
}
295295
for (let id in second) {
296296
if (!hasProperty(result, id)) {
297-
result[id] = second[id];
297+
(result as any)[id] = second[id];
298298
}
299299
}
300300
return result;

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ namespace ts {
511511
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
512512
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
513513
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
514+
You_already_have_a_tsconfig_json_file_defined: { code: 5054, category: DiagnosticCategory.Error, key: "You already have a tsconfig.json file defined." },
514515
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
515516
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
516517
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -566,6 +567,9 @@ namespace ts {
566567
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
567568
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
568569
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
570+
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
571+
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
572+
569573
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
570574
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
571575
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },

src/compiler/diagnosticMessages.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
},
162162
"Type '{0}' is not a valid async function return type.": {
163163
"category": "Error",
164-
"code": 1055
164+
"code": 1055
165165
},
166166
"Accessors are only available when targeting ECMAScript 5 and higher.": {
167167
"category": "Error",
@@ -2033,7 +2033,15 @@
20332033
"category": "Error",
20342034
"code": 5053
20352035
},
2036+
<<<<<<< HEAD
20362037

2038+
=======
2039+
"You already have a tsconfig.json file defined.": {
2040+
"category": "Error",
2041+
"code": 5052
2042+
},
2043+
2044+
>>>>>>> 1670ce9664ed914ba2cd7c172caf8fe905261a81
20372045
"Concatenate and emit output to single file.": {
20382046
"category": "Message",
20392047
"code": 6001
@@ -2250,10 +2258,21 @@
22502258
"category": "Message",
22512259
"code": 6068
22522260
},
2261+
<<<<<<< HEAD
22532262
"Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .": {
22542263
"category": "Message",
22552264
"code": 6069
22562265
},
2266+
=======
2267+
"Initializes a TypeScript project and creates a tsconfig.json file.": {
2268+
"category": "Message",
2269+
"code": 6069
2270+
},
2271+
"Successfully created a tsconfig.json file.": {
2272+
"category": "Message",
2273+
"code": 6070
2274+
},
2275+
>>>>>>> 1670ce9664ed914ba2cd7c172caf8fe905261a81
22572276

22582277
"Variable '{0}' implicitly has an '{1}' type.": {
22592278
"category": "Error",

0 commit comments

Comments
 (0)