Skip to content

Commit bf854a7

Browse files
author
Kanchalai Tanglertsampan
committed
Merge branch 'master' into fix4211
2 parents e910e71 + 6648403 commit bf854a7

File tree

282 files changed

+10389
-1311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

282 files changed

+10389
-1311
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"jake": "latest",
33-
"mocha": "latest",
33+
"mocha": "2.3.4",
3434
"chai": "latest",
3535
"browserify": "latest",
3636
"istanbul": "latest",

src/compiler/checker.ts

Lines changed: 414 additions & 275 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 91 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ namespace ts {
255255
name: "moduleResolution",
256256
type: {
257257
"node": ModuleResolutionKind.NodeJs,
258-
"classic": ModuleResolutionKind.Classic
258+
"classic": ModuleResolutionKind.Classic,
259259
},
260260
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
261261
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
@@ -286,14 +286,40 @@ namespace ts {
286286
description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
287287
},
288288
{
289-
name: "allowSyntheticDefaultImports",
289+
name: "baseUrl",
290+
type: "string",
291+
isFilePath: true,
292+
description: Diagnostics.Base_directory_to_resolve_non_absolute_module_names
293+
},
294+
{
295+
// this option can only be specified in tsconfig.json
296+
// use type = object to copy the value as-is
297+
name: "paths",
298+
type: "object",
299+
isTSConfigOnly: true
300+
},
301+
{
302+
// this option can only be specified in tsconfig.json
303+
// use type = object to copy the value as-is
304+
name: "rootDirs",
305+
type: "object",
306+
isTSConfigOnly: true,
307+
isFilePath: true
308+
},
309+
{
310+
name: "traceModuleResolution",
290311
type: "boolean",
291-
description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
312+
description: Diagnostics.Enable_tracing_of_the_module_resolution_process
292313
},
293314
{
294315
name: "allowJs",
295316
type: "boolean",
296317
description: Diagnostics.Allow_javascript_files_to_be_compiled
318+
},
319+
{
320+
name: "allowSyntheticDefaultImports",
321+
type: "boolean",
322+
description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
297323
}
298324
];
299325

@@ -355,34 +381,39 @@ namespace ts {
355381
if (hasProperty(optionNameMap, s)) {
356382
const opt = optionNameMap[s];
357383

358-
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
359-
if (!args[i] && opt.type !== "boolean") {
360-
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_expects_an_argument, opt.name));
384+
if (opt.isTSConfigOnly) {
385+
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name));
361386
}
387+
else {
388+
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
389+
if (!args[i] && opt.type !== "boolean") {
390+
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_expects_an_argument, opt.name));
391+
}
362392

363-
switch (opt.type) {
364-
case "number":
365-
options[opt.name] = parseInt(args[i]);
366-
i++;
367-
break;
368-
case "boolean":
369-
options[opt.name] = true;
370-
break;
371-
case "string":
372-
options[opt.name] = args[i] || "";
373-
i++;
374-
break;
375-
// If not a primitive, the possible types are specified in what is effectively a map of options.
376-
default:
377-
let map = <Map<number>>opt.type;
378-
let key = (args[i] || "").toLowerCase();
379-
i++;
380-
if (hasProperty(map, key)) {
381-
options[opt.name] = map[key];
382-
}
383-
else {
384-
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
385-
}
393+
switch (opt.type) {
394+
case "number":
395+
options[opt.name] = parseInt(args[i]);
396+
i++;
397+
break;
398+
case "boolean":
399+
options[opt.name] = true;
400+
break;
401+
case "string":
402+
options[opt.name] = args[i] || "";
403+
i++;
404+
break;
405+
// If not a primitive, the possible types are specified in what is effectively a map of options.
406+
default:
407+
let map = <Map<number>>opt.type;
408+
let key = (args[i] || "").toLowerCase();
409+
i++;
410+
if (hasProperty(map, key)) {
411+
options[opt.name] = map[key];
412+
}
413+
else {
414+
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
415+
}
416+
}
386417
}
387418
}
388419
else {
@@ -485,7 +516,6 @@ namespace ts {
485516
return output;
486517
}
487518

488-
489519
/**
490520
* Parse the contents of a config file (tsconfig.json).
491521
* @param json The contents of the config file to parse
@@ -497,6 +527,7 @@ namespace ts {
497527
const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName);
498528

499529
const options = extend(existingOptions, optionsFromJsonConfigFile);
530+
500531
return {
501532
options,
502533
fileNames: getFileNames(),
@@ -580,7 +611,36 @@ namespace ts {
580611
}
581612
}
582613
if (opt.isFilePath) {
583-
value = normalizePath(combinePaths(basePath, value));
614+
switch (typeof value) {
615+
case "string":
616+
value = normalizePath(combinePaths(basePath, value));
617+
break;
618+
case "object":
619+
// "object" options with 'isFilePath' = true expected to be string arrays
620+
let paths: string[] = [];
621+
let invalidOptionType = false;
622+
if (!isArray(value)) {
623+
invalidOptionType = true;
624+
}
625+
else {
626+
for (const element of <any[]>value) {
627+
if (typeof element === "string") {
628+
paths.push(normalizePath(combinePaths(basePath, element)));
629+
}
630+
else {
631+
invalidOptionType = true;
632+
break;
633+
}
634+
}
635+
}
636+
if (invalidOptionType) {
637+
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name));
638+
}
639+
else {
640+
value = paths;
641+
}
642+
break;
643+
}
584644
if (value === "") {
585645
value = ".";
586646
}

src/compiler/core.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ namespace ts {
7474
GreaterThan = 1
7575
}
7676

77-
export interface StringSet extends Map<any> { }
78-
7977
/**
8078
* Iterates through 'array' by index and performs the callback on each element of array until the callback
8179
* returns a truthy value, then returns that value.
@@ -441,6 +439,17 @@ namespace ts {
441439
};
442440
}
443441

442+
/* internal */
443+
export function formatMessage(dummy: any, message: DiagnosticMessage): string {
444+
let text = getLocaleSpecificMessage(message);
445+
446+
if (arguments.length > 2) {
447+
text = formatStringFromArgs(text, arguments, 2);
448+
}
449+
450+
return text;
451+
}
452+
444453
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
445454
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
446455
let text = getLocaleSpecificMessage(message);

0 commit comments

Comments
 (0)