Skip to content

Commit b83b4a8

Browse files
committed
Merge pull request #4508 from Microsoft/mergeMasterInRelease1.6
Merge master in release1.6
2 parents 3f751a7 + 2fe37c0 commit b83b4a8

33 files changed

+947
-144
lines changed

lib/tsc.js

Lines changed: 107 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ var ts;
14291429
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
14301430
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
14311431
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
1432-
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
1432+
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
14331433
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
14341434
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
14351435
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -1515,6 +1515,7 @@ var ts;
15151515
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
15161516
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
15171517
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
1518+
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
15181519
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
15191520
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
15201521
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -1570,6 +1571,8 @@ var ts;
15701571
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
15711572
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
15721573
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
1574+
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
1575+
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
15731576
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
15741577
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
15751578
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -3630,6 +3633,9 @@ var ts;
36303633
else {
36313634
var bindingName = node.name ? node.name.text : "__class";
36323635
bindAnonymousDeclaration(node, 32, bindingName);
3636+
if (node.name) {
3637+
classifiableNames[node.name.text] = node.name.text;
3638+
}
36333639
}
36343640
var symbol = node.symbol;
36353641
var prototypeSymbol = createSymbol(4 | 134217728, "prototype");
@@ -13825,6 +13831,15 @@ var ts;
1382513831
return result;
1382613832
}
1382713833
function instantiateAnonymousType(type, mapper) {
13834+
if (mapper.instantiations) {
13835+
var cachedType = mapper.instantiations[type.id];
13836+
if (cachedType) {
13837+
return cachedType;
13838+
}
13839+
}
13840+
else {
13841+
mapper.instantiations = [];
13842+
}
1382813843
var result = createObjectType(65536 | 131072, type.symbol);
1382913844
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
1383013845
result.members = createSymbolTable(result.properties);
@@ -13836,6 +13851,7 @@ var ts;
1383613851
result.stringIndexType = instantiateType(stringIndexType, mapper);
1383713852
if (numberIndexType)
1383813853
result.numberIndexType = instantiateType(numberIndexType, mapper);
13854+
mapper.instantiations[type.id] = result;
1383913855
return result;
1384013856
}
1384113857
function instantiateType(type, mapper) {
@@ -20063,7 +20079,7 @@ var ts;
2006320079
}
2006420080
if (!isDefinedBefore(propertyDecl, member)) {
2006520081
reportError = false;
20066-
error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
20082+
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
2006720083
return undefined;
2006820084
}
2006920085
return getNodeLinks(propertyDecl).enumMemberValue;
@@ -23679,11 +23695,7 @@ var ts;
2367923695
}
2368023696
function emitJavaScript(jsFilePath, root) {
2368123697
var writer = ts.createTextWriter(newLine);
23682-
var write = writer.write;
23683-
var writeTextOfNode = writer.writeTextOfNode;
23684-
var writeLine = writer.writeLine;
23685-
var increaseIndent = writer.increaseIndent;
23686-
var decreaseIndent = writer.decreaseIndent;
23698+
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
2368723699
var currentSourceFile;
2368823700
var exportFunctionForFile;
2368923701
var generatedNameSet = {};
@@ -29350,6 +29362,7 @@ var ts;
2935029362
})(ts || (ts = {}));
2935129363
/// <reference path="sys.ts" />
2935229364
/// <reference path="emitter.ts" />
29365+
/// <reference path="core.ts" />
2935329366
var ts;
2935429367
(function (ts) {
2935529368
ts.programTime = 0;
@@ -29532,6 +29545,14 @@ var ts;
2953229545
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
2953329546
}
2953429547
ts.classicNameResolver = classicNameResolver;
29548+
ts.defaultInitCompilerOptions = {
29549+
module: 1,
29550+
target: 0,
29551+
noImplicitAny: false,
29552+
outDir: "built",
29553+
rootDir: ".",
29554+
sourceMap: false
29555+
};
2953529556
function createCompilerHost(options, setParentNodes) {
2953629557
var currentDirectory;
2953729558
var existingDirectories = {};
@@ -30202,6 +30223,11 @@ var ts;
3020230223
type: "boolean",
3020330224
description: ts.Diagnostics.Print_this_message
3020430225
},
30226+
{
30227+
name: "init",
30228+
type: "boolean",
30229+
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
30230+
},
3020530231
{
3020630232
name: "inlineSourceMap",
3020730233
type: "boolean"
@@ -30407,18 +30433,28 @@ var ts;
3040730433
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
3040830434
}
3040930435
];
30410-
function parseCommandLine(commandLine) {
30411-
var options = {};
30412-
var fileNames = [];
30413-
var errors = [];
30414-
var shortOptionNames = {};
30436+
var optionNameMapCache;
30437+
function getOptionNameMap() {
30438+
if (optionNameMapCache) {
30439+
return optionNameMapCache;
30440+
}
3041530441
var optionNameMap = {};
30442+
var shortOptionNames = {};
3041630443
ts.forEach(ts.optionDeclarations, function (option) {
3041730444
optionNameMap[option.name.toLowerCase()] = option;
3041830445
if (option.shortName) {
3041930446
shortOptionNames[option.shortName] = option.name;
3042030447
}
3042130448
});
30449+
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
30450+
return optionNameMapCache;
30451+
}
30452+
ts.getOptionNameMap = getOptionNameMap;
30453+
function parseCommandLine(commandLine) {
30454+
var options = {};
30455+
var fileNames = [];
30456+
var errors = [];
30457+
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
3042230458
parseStrings(commandLine);
3042330459
return {
3042430460
options: options,
@@ -30734,6 +30770,10 @@ var ts;
3073430770
reportDiagnostics(commandLine.errors);
3073530771
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
3073630772
}
30773+
if (commandLine.options.init) {
30774+
writeConfigFile(commandLine.options, commandLine.fileNames);
30775+
return ts.sys.exit(ts.ExitStatus.Success);
30776+
}
3073730777
if (commandLine.options.version) {
3073830778
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version));
3073930779
return ts.sys.exit(ts.ExitStatus.Success);
@@ -30975,5 +31015,60 @@ var ts;
3097531015
return Array(paddingLength + 1).join(" ");
3097631016
}
3097731017
}
31018+
function writeConfigFile(options, fileNames) {
31019+
var currentDirectory = ts.sys.getCurrentDirectory();
31020+
var file = ts.combinePaths(currentDirectory, 'tsconfig.json');
31021+
if (ts.sys.fileExists(file)) {
31022+
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
31023+
}
31024+
else {
31025+
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
31026+
var configurations = {
31027+
compilerOptions: serializeCompilerOptions(compilerOptions),
31028+
exclude: ["node_modules"]
31029+
};
31030+
if (fileNames && fileNames.length) {
31031+
configurations.files = fileNames;
31032+
}
31033+
ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
31034+
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
31035+
}
31036+
return;
31037+
function serializeCompilerOptions(options) {
31038+
var result = {};
31039+
var optionsNameMap = ts.getOptionNameMap().optionNameMap;
31040+
for (var name_28 in options) {
31041+
if (ts.hasProperty(options, name_28)) {
31042+
var value = options[name_28];
31043+
switch (name_28) {
31044+
case "init":
31045+
case "watch":
31046+
case "version":
31047+
case "help":
31048+
case "project":
31049+
break;
31050+
default:
31051+
var optionDefinition = optionsNameMap[name_28.toLowerCase()];
31052+
if (optionDefinition) {
31053+
if (typeof optionDefinition.type === "string") {
31054+
result[name_28] = value;
31055+
}
31056+
else {
31057+
var typeMap = optionDefinition.type;
31058+
for (var key in typeMap) {
31059+
if (ts.hasProperty(typeMap, key)) {
31060+
if (typeMap[key] === value)
31061+
result[name_28] = key;
31062+
}
31063+
}
31064+
}
31065+
}
31066+
break;
31067+
}
31068+
}
31069+
}
31070+
return result;
31071+
}
31072+
}
3097831073
})(ts || (ts = {}));
3097931074
ts.executeCommandLine(ts.sys.args);

0 commit comments

Comments
 (0)