Merge pull request #4508 from Microsoft/mergeMasterInRelease1.6

Merge master in release1.6
This commit is contained in:
Mohamed Hegazy 2015-08-27 16:10:06 -07:00
commit b83b4a8d5a
33 changed files with 947 additions and 144 deletions

View File

@ -1429,7 +1429,7 @@ var ts;
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" },
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" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
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." },
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." },
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." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
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;
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." },
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}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
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}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
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;
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." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
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) ." },
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." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
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;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32, bindingName);
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
var prototypeSymbol = createSymbol(4 | 134217728, "prototype");
@ -13825,6 +13831,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
var result = createObjectType(65536 | 131072, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
result.members = createSymbolTable(result.properties);
@ -13836,6 +13851,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@ -20063,7 +20079,7 @@ var ts;
}
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
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);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@ -23679,11 +23695,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
var exportFunctionForFile;
var generatedNameSet = {};
@ -29350,6 +29362,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
ts.programTime = 0;
@ -29532,6 +29545,14 @@ var ts;
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
ts.defaultInitCompilerOptions = {
module: 1,
target: 0,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@ -30202,6 +30223,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@ -30407,18 +30433,28 @@ var ts;
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@ -30734,6 +30770,10 @@ var ts;
reportDiagnostics(commandLine.errors);
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.options.init) {
writeConfigFile(commandLine.options, commandLine.fileNames);
return ts.sys.exit(ts.ExitStatus.Success);
}
if (commandLine.options.version) {
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version));
return ts.sys.exit(ts.ExitStatus.Success);
@ -30975,5 +31015,60 @@ var ts;
return Array(paddingLength + 1).join(" ");
}
}
function writeConfigFile(options, fileNames) {
var currentDirectory = ts.sys.getCurrentDirectory();
var file = ts.combinePaths(currentDirectory, 'tsconfig.json');
if (ts.sys.fileExists(file)) {
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
}
else {
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
var configurations = {
compilerOptions: serializeCompilerOptions(compilerOptions),
exclude: ["node_modules"]
};
if (fileNames && fileNames.length) {
configurations.files = fileNames;
}
ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
}
return;
function serializeCompilerOptions(options) {
var result = {};
var optionsNameMap = ts.getOptionNameMap().optionNameMap;
for (var name_28 in options) {
if (ts.hasProperty(options, name_28)) {
var value = options[name_28];
switch (name_28) {
case "init":
case "watch":
case "version":
case "help":
case "project":
break;
default:
var optionDefinition = optionsNameMap[name_28.toLowerCase()];
if (optionDefinition) {
if (typeof optionDefinition.type === "string") {
result[name_28] = value;
}
else {
var typeMap = optionDefinition.type;
for (var key in typeMap) {
if (ts.hasProperty(typeMap, key)) {
if (typeMap[key] === value)
result[name_28] = key;
}
}
}
}
break;
}
}
}
return result;
}
}
})(ts || (ts = {}));
ts.executeCommandLine(ts.sys.args);

View File

@ -1429,7 +1429,7 @@ var ts;
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" },
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" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
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." },
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." },
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." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
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;
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." },
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}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
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}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
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;
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." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
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) ." },
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." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -3007,6 +3010,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@ -3212,18 +3220,28 @@ var ts;
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@ -10585,6 +10603,9 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32, bindingName);
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
var prototypeSymbol = createSymbol(4 | 134217728, "prototype");
@ -14266,6 +14287,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
var result = createObjectType(65536 | 131072, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
result.members = createSymbolTable(result.properties);
@ -14277,6 +14307,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@ -20504,7 +20535,7 @@ var ts;
}
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
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);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@ -24120,11 +24151,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
var exportFunctionForFile;
var generatedNameSet = {};
@ -29791,6 +29818,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
ts.programTime = 0;
@ -29973,6 +30001,14 @@ var ts;
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
ts.defaultInitCompilerOptions = {
module: 1,
target: 0,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@ -33520,6 +33556,18 @@ var ts;
this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2));
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2));
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.HighPriorityCommonRules =
[
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
@ -33545,6 +33593,11 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
this.SpaceAfterModuleName,
@ -35247,6 +35300,7 @@ var ts;
case 212:
case 213:
case 215:
case 214:
case 162:
case 190:
case 217:
@ -35268,6 +35322,16 @@ var ts;
case 160:
case 159:
case 231:
case 140:
case 145:
case 146:
case 136:
case 150:
case 151:
case 156:
case 158:
case 168:
case 176:
return true;
}
return false;
@ -35286,8 +35350,6 @@ var ts;
case 211:
case 171:
case 141:
case 140:
case 145:
case 172:
case 142:
case 143:

1
lib/typescript.d.ts vendored
View File

@ -1304,6 +1304,7 @@ declare module "typescript" {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;

View File

@ -2298,7 +2298,7 @@ var ts;
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" },
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" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
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." },
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." },
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." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
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}'." },
@ -2384,6 +2384,7 @@ var ts;
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." },
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}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
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}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
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." },
@ -2439,6 +2440,8 @@ var ts;
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." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
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) ." },
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." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -4855,6 +4858,10 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32 /* Class */, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
// TypeScript 1.0 spec (April 2014): 8.4
@ -16963,6 +16970,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@ -16975,6 +16991,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@ -24634,7 +24651,7 @@ var ts;
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
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);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@ -28581,11 +28598,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
// name of an exporter function if file is a System external module
// System.register([...], function (<exporter>) {...})
@ -31169,7 +31182,7 @@ var ts;
if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === 1 /* ES5 */) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@ -32840,7 +32853,7 @@ var ts;
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case 212 /* ClassDeclaration */:
@ -32974,7 +32987,7 @@ var ts;
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
var valueDeclaration;
@ -35120,6 +35133,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
/* @internal */ ts.programTime = 0;
@ -35310,6 +35324,15 @@ var ts;
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
/* @internal */
ts.defaultInitCompilerOptions = {
module: 1 /* CommonJS */,
target: 0 /* ES3 */,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@ -36054,6 +36077,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@ -36260,18 +36288,29 @@ var ts;
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
/* @internal */
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@ -39710,6 +39749,22 @@ var ts;
this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */));
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Type alias declaration
this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// union type
this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@ -39736,6 +39791,11 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@ -41679,6 +41739,7 @@ var ts;
case 212 /* ClassDeclaration */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 214 /* TypeAliasDeclaration */:
case 162 /* ArrayLiteralExpression */:
case 190 /* Block */:
case 217 /* ModuleBlock */:
@ -41700,6 +41761,16 @@ var ts;
case 160 /* ArrayBindingPattern */:
case 159 /* ObjectBindingPattern */:
case 231 /* JsxElement */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 146 /* ConstructSignature */:
case 136 /* Parameter */:
case 150 /* FunctionType */:
case 151 /* ConstructorType */:
case 156 /* UnionType */:
case 158 /* ParenthesizedType */:
case 168 /* TaggedTemplateExpression */:
case 176 /* AwaitExpression */:
return true;
}
return false;
@ -41718,8 +41789,6 @@ var ts;
case 211 /* FunctionDeclaration */:
case 171 /* FunctionExpression */:
case 141 /* MethodDeclaration */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 172 /* ArrowFunction */:
case 142 /* Constructor */:
case 143 /* GetAccessor */:

View File

@ -1304,6 +1304,7 @@ declare namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;

View File

@ -2298,7 +2298,7 @@ var ts;
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" },
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" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
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." },
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." },
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." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
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}'." },
@ -2384,6 +2384,7 @@ var ts;
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." },
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}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
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}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
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." },
@ -2439,6 +2440,8 @@ var ts;
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." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
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) ." },
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." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -4855,6 +4858,10 @@ var ts;
else {
var bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, 32 /* Class */, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
var symbol = node.symbol;
// TypeScript 1.0 spec (April 2014): 8.4
@ -16963,6 +16970,15 @@ var ts;
return result;
}
function instantiateAnonymousType(type, mapper) {
if (mapper.instantiations) {
var cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@ -16975,6 +16991,7 @@ var ts;
result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType)
result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
@ -24634,7 +24651,7 @@ var ts;
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
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);
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
return getNodeLinks(propertyDecl).enumMemberValue;
@ -28581,11 +28598,7 @@ var ts;
}
function emitJavaScript(jsFilePath, root) {
var writer = ts.createTextWriter(newLine);
var write = writer.write;
var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent;
var currentSourceFile;
// name of an exporter function if file is a System external module
// System.register([...], function (<exporter>) {...})
@ -31169,7 +31182,7 @@ var ts;
if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === 1 /* ES5 */) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@ -32840,7 +32853,7 @@ var ts;
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case 212 /* ClassDeclaration */:
@ -32974,7 +32987,7 @@ var ts;
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
var valueDeclaration;
@ -35120,6 +35133,7 @@ var ts;
})(ts || (ts = {}));
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
var ts;
(function (ts) {
/* @internal */ ts.programTime = 0;
@ -35310,6 +35324,15 @@ var ts;
return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations };
}
ts.classicNameResolver = classicNameResolver;
/* @internal */
ts.defaultInitCompilerOptions = {
module: 1 /* CommonJS */,
target: 0 /* ES3 */,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false
};
function createCompilerHost(options, setParentNodes) {
var currentDirectory;
var existingDirectories = {};
@ -36054,6 +36077,11 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Print_this_message
},
{
name: "init",
type: "boolean",
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file
},
{
name: "inlineSourceMap",
type: "boolean"
@ -36260,18 +36288,29 @@ var ts;
description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var shortOptionNames = {};
var optionNameMapCache;
/* @internal */
function getOptionNameMap() {
if (optionNameMapCache) {
return optionNameMapCache;
}
var optionNameMap = {};
var shortOptionNames = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
return optionNameMapCache;
}
ts.getOptionNameMap = getOptionNameMap;
function parseCommandLine(commandLine) {
var options = {};
var fileNames = [];
var errors = [];
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
parseStrings(commandLine);
return {
options: options,
@ -39710,6 +39749,22 @@ var ts;
this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */));
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Type alias declaration
this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// union type
this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@ -39736,6 +39791,11 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@ -41679,6 +41739,7 @@ var ts;
case 212 /* ClassDeclaration */:
case 213 /* InterfaceDeclaration */:
case 215 /* EnumDeclaration */:
case 214 /* TypeAliasDeclaration */:
case 162 /* ArrayLiteralExpression */:
case 190 /* Block */:
case 217 /* ModuleBlock */:
@ -41700,6 +41761,16 @@ var ts;
case 160 /* ArrayBindingPattern */:
case 159 /* ObjectBindingPattern */:
case 231 /* JsxElement */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 146 /* ConstructSignature */:
case 136 /* Parameter */:
case 150 /* FunctionType */:
case 151 /* ConstructorType */:
case 156 /* UnionType */:
case 158 /* ParenthesizedType */:
case 168 /* TaggedTemplateExpression */:
case 176 /* AwaitExpression */:
return true;
}
return false;
@ -41718,8 +41789,6 @@ var ts;
case 211 /* FunctionDeclaration */:
case 171 /* FunctionExpression */:
case 141 /* MethodDeclaration */:
case 140 /* MethodSignature */:
case 145 /* CallSignature */:
case 172 /* ArrowFunction */:
case 142 /* Constructor */:
case 143 /* GetAccessor */:

View File

@ -4487,6 +4487,15 @@ namespace ts {
}
function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType {
if (mapper.instantiations) {
let cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
let result = <ResolvedType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@ -4497,6 +4506,7 @@ namespace ts {
let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}

View File

@ -30,6 +30,11 @@ namespace ts {
type: "boolean",
description: Diagnostics.Print_this_message,
},
{
name: "init",
type: "boolean",
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
},
{
name: "inlineSourceMap",
type: "boolean",
@ -237,19 +242,38 @@ namespace ts {
}
];
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let shortOptionNames: Map<string> = {};
let optionNameMap: Map<CommandLineOption> = {};
/* @internal */
export interface OptionNameMap {
optionNameMap: Map<CommandLineOption>;
shortOptionNames: Map<string>;
}
let optionNameMapCache: OptionNameMap;
/* @internal */
export function getOptionNameMap(): OptionNameMap {
if (optionNameMapCache) {
return optionNameMapCache;
}
let optionNameMap: Map<CommandLineOption> = {};
let shortOptionNames: Map<string> = {};
forEach(optionDeclarations, option => {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap, shortOptionNames };
return optionNameMapCache;
}
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let { optionNameMap, shortOptionNames } = getOptionNameMap();
parseStrings(commandLine);
return {
options,

View File

@ -287,14 +287,14 @@ namespace ts {
return <T>result;
}
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
let result: Map<T> = {};
export function extend<T1, T2>(first: Map<T1>, second: Map<T2>): Map<T1 & T2> {
let result: Map<T1 & T2> = {};
for (let id in first) {
result[id] = first[id];
(result as any)[id] = first[id];
}
for (let id in second) {
if (!hasProperty(result, id)) {
result[id] = second[id];
(result as any)[id] = second[id];
}
}
return result;

View File

@ -511,6 +511,7 @@ namespace ts {
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." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
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,8 @@ namespace ts {
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." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
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) ." },
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." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },

View File

@ -161,7 +161,7 @@
},
"Type '{0}' is not a valid async function return type.": {
"category": "Error",
"code": 1055
"code": 1055
},
"Accessors are only available when targeting ECMAScript 5 and higher.": {
"category": "Error",
@ -2033,7 +2033,11 @@
"category": "Error",
"code": 5053
},
"A 'tsconfig.json' file is already defined at: '{0}'.": {
"category": "Error",
"code": 5053
},
"Concatenate and emit output to single file.": {
"category": "Message",
"code": 6001
@ -2254,6 +2258,14 @@
"category": "Message",
"code": 6069
},
"Initializes a TypeScript project and creates a tsconfig.json file.": {
"category": "Message",
"code": 6070
},
"Successfully created a tsconfig.json file.": {
"category": "Message",
"code": 6071
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",

View File

@ -124,11 +124,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitJavaScript(jsFilePath: string, root?: SourceFile) {
let writer = createTextWriter(newLine);
let write = writer.write;
let writeTextOfNode = writer.writeTextOfNode;
let writeLine = writer.writeLine;
let increaseIndent = writer.increaseIndent;
let decreaseIndent = writer.decreaseIndent;
let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;
let currentSourceFile: SourceFile;
// name of an exporter function if file is a System external module
@ -2114,7 +2110,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emit(node.name);
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
}
function emitQualifiedName(node: QualifiedName) {
emit(node.left);
write(".");
@ -2137,12 +2133,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
emitEntityNameAsExpression(node.left, /*useFallback*/ false);
}
write(".");
emit(node.right);
}
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
switch (node.kind) {
case SyntaxKind.Identifier:
if (useFallback) {
@ -2150,10 +2146,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitExpressionIdentifier(<Identifier>node);
write(" !== 'undefined' && ");
}
emitExpressionIdentifier(<Identifier>node);
break;
case SyntaxKind.QualifiedName:
emitQualifiedNameAsExpression(<QualifiedName>node, useFallback);
break;
@ -3064,7 +3060,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === ScriptTarget.ES5) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@ -4320,7 +4316,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (ctor) {
// Emit all the directive prologues (like "use strict"). These have to come before
// any other preamble code we write (like parameter initializers).
startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true);
startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true);
emitDetachedComments(ctor.body.statements);
}
emitCaptureThisForNodeIfNecessary(node);
@ -4892,7 +4888,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
return false;
}
/** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */
function emitSerializedTypeOfNode(node: Node) {
// serialization of the type of a declaration uses the following rules:
@ -4903,39 +4899,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
write("Function");
return;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertyDeclaration:
emitSerializedTypeNode((<PropertyDeclaration>node).type);
return;
case SyntaxKind.Parameter:
case SyntaxKind.Parameter:
emitSerializedTypeNode((<ParameterDeclaration>node).type);
return;
case SyntaxKind.GetAccessor:
case SyntaxKind.GetAccessor:
emitSerializedTypeNode((<AccessorDeclaration>node).type);
return;
case SyntaxKind.SetAccessor:
case SyntaxKind.SetAccessor:
emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(<AccessorDeclaration>node));
return;
}
if (isFunctionLike(node)) {
write("Function");
return;
}
write("void 0");
}
function emitSerializedTypeNode(node: TypeNode) {
if (!node) {
return;
@ -4949,17 +4945,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.ParenthesizedType:
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
return;
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
write("Function");
return;
case SyntaxKind.ArrayType:
case SyntaxKind.TupleType:
write("Array");
return;
case SyntaxKind.TypePredicate:
case SyntaxKind.BooleanKeyword:
write("Boolean");
@ -4969,11 +4965,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.StringLiteral:
write("String");
return;
case SyntaxKind.NumberKeyword:
write("Number");
return;
case SyntaxKind.SymbolKeyword:
write("Symbol");
return;
@ -4981,22 +4977,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.TypeReference:
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
return;
case SyntaxKind.TypeQuery:
case SyntaxKind.TypeLiteral:
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
case SyntaxKind.AnyKeyword:
break;
default:
Debug.fail("Cannot serialize unexpected type node.");
break;
}
write("Object");
}
/** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */
function emitSerializedTypeReferenceNode(node: TypeReferenceNode) {
let location: Node = node.parent;
@ -5024,27 +5020,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
emitEntityNameAsExpression(typeName, /*useFallback*/ false);
break;
case TypeReferenceSerializationKind.VoidType:
write("void 0");
break;
case TypeReferenceSerializationKind.BooleanType:
write("Boolean");
break;
case TypeReferenceSerializationKind.NumberLikeType:
write("Number");
break;
case TypeReferenceSerializationKind.StringLikeType:
write("String");
break;
case TypeReferenceSerializationKind.ArrayLikeType:
write("Array");
break;
case TypeReferenceSerializationKind.ESSymbolType:
if (languageVersion < ScriptTarget.ES6) {
write("typeof Symbol === 'function' ? Symbol : Object");
@ -5053,24 +5049,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("Symbol");
}
break;
case TypeReferenceSerializationKind.TypeWithCallSignature:
write("Function");
break;
case TypeReferenceSerializationKind.ObjectType:
write("Object");
break;
}
}
/** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */
function emitSerializedParameterTypesOfNode(node: Node) {
// serialization of parameter types uses the following rules:
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
let valueDeclaration: FunctionLikeDeclaration;
@ -5080,7 +5076,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else if (isFunctionLike(node) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
valueDeclaration = <FunctionLikeDeclaration>node;
}
if (valueDeclaration) {
const parameters = valueDeclaration.parameters;
const parameterCount = parameters.length;
@ -5089,7 +5085,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (i > 0) {
write(", ");
}
if (parameters[i].dotDotDotToken) {
let parameterType = parameters[i].type;
if (parameterType.kind === SyntaxKind.ArrayType) {
@ -5101,7 +5097,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
parameterType = undefined;
}
emitSerializedTypeNode(parameterType);
}
else {
@ -5112,18 +5108,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
}
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node): string | string[] {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
write("void 0");
}
function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number {
// This method emits the serialized type metadata for a decorator target.
// The caller should have already tested whether the node has decorators.
@ -5153,7 +5149,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (writeComma || argumentsWritten) {
write(", ");
}
writeLine();
write("__metadata('design:returntype', ");
emitSerializedReturnTypeOfNode(node);
@ -5161,10 +5157,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
argumentsWritten++;
}
}
return argumentsWritten;
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
emitOnlyPinnedOrTripleSlashComments(node);
}
@ -5530,18 +5526,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
(!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) {
emitLeadingComments(node);
emitStart(node);
// variable declaration for import-equals declaration can be hoisted in system modules
// in this case 'var' should be omitted and emit should contain only initialization
let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true);
// is it top level export import v = a.b.c in system module?
// if yes - it needs to be rewritten as exporter('v', v = a.b.c)
let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true);
if (!variableDeclarationIsHoisted) {
Debug.assert(!isExported);
if (isES6ExportedDeclaration(node)) {
write("export ");
write("var ");
@ -5550,8 +5546,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("var ");
}
}
if (isExported) {
write(`${exportFunctionForFile}("`);
emitNodeWithoutSourceMap(node.name);
@ -5565,8 +5561,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (isExported) {
write(")");
}
write(";");
write(";");
emitEnd(node);
emitExportImportAssignments(node);
emitTrailingComments(node);
@ -6088,12 +6084,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
return;
}
if (isInternalModuleImportEqualsDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
hoistedVars.push(node.name);
return;
}

View File

@ -1,5 +1,6 @@
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
namespace ts {
/* @internal */ export let programTime = 0;
@ -224,6 +225,16 @@ namespace ts {
return { resolvedFileName: referencedSourceFile, failedLookupLocations };
}
/* @internal */
export const defaultInitCompilerOptions: CompilerOptions = {
module: ModuleKind.CommonJS,
target: ScriptTarget.ES3,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false,
};
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
let currentDirectory: string;
let existingDirectories: Map<boolean> = {};

View File

@ -159,6 +159,11 @@ namespace ts {
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.options.init) {
writeConfigFile(commandLine.options, commandLine.fileNames);
return sys.exit(ExitStatus.Success);
}
if (commandLine.options.version) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version));
return sys.exit(ExitStatus.Success);
@ -489,6 +494,70 @@ namespace ts {
return Array(paddingLength + 1).join(" ");
}
}
function writeConfigFile(options: CompilerOptions, fileNames: string[]) {
let currentDirectory = sys.getCurrentDirectory();
let file = combinePaths(currentDirectory, 'tsconfig.json');
if (sys.fileExists(file)) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
}
else {
let compilerOptions = extend(options, defaultInitCompilerOptions);
let configurations: any = {
compilerOptions: serializeCompilerOptions(compilerOptions),
exclude: ["node_modules"]
};
if (fileNames && fileNames.length) {
// only set the files property if we have at least one file
configurations.files = fileNames;
}
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file));
}
return;
function serializeCompilerOptions(options: CompilerOptions): Map<string|number|boolean> {
let result: Map<string|number|boolean> = {};
let optionsNameMap = getOptionNameMap().optionNameMap;
for (let name in options) {
if (hasProperty(options, name)) {
let value = options[name];
switch (name) {
case "init":
case "watch":
case "version":
case "help":
case "project":
break;
default:
let optionDefinition = optionsNameMap[name.toLowerCase()];
if (optionDefinition) {
if (typeof optionDefinition.type === "string") {
// string, number or boolean
result[name] = value;
}
else {
// Enum
let typeMap = <Map<number>>optionDefinition.type;
for (let key in typeMap) {
if (hasProperty(typeMap, key)) {
if (typeMap[key] === value)
result[name] = key;
}
}
}
}
break;
}
}
}
return result;
}
}
}
ts.executeCommandLine(ts.sys.args);

View File

@ -1552,8 +1552,8 @@ namespace ts {
export interface SymbolAccessiblityResult extends SymbolVisibilityResult {
errorModuleName?: string; // If the symbol is not visible from module, module's name
}
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
* metadata */
/* @internal */
export enum TypeReferenceSerializationKind {
@ -1953,6 +1953,7 @@ namespace ts {
/* @internal */
export interface TypeMapper {
(t: TypeParameter): Type;
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
context?: InferenceContext; // The inference context this mapper was created from.
// Only inference mappers have this set (in createInferenceMapper).
// The identity mapper and regular instantiation mappers do not need it.
@ -2022,6 +2023,7 @@ namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;

View File

@ -213,6 +213,26 @@ namespace ts.formatting {
public NoSpaceBetweenYieldKeywordAndStar: Rule;
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
// Async-await
public SpaceBetweenAsyncAndFunctionKeyword: Rule;
public NoSpaceBetweenAsyncAndFunctionKeyword: Rule;
public SpaceAfterAwaitKeyword: Rule;
public NoSpaceAfterAwaitKeyword: Rule;
// Type alias declaration
public SpaceAfterTypeKeyword: Rule;
public NoSpaceAfterTypeKeyword: Rule;
// Tagged template string
public SpaceBetweenTagAndTemplateString: Rule;
public NoSpaceBetweenTagAndTemplateString: Rule;
// Union type
public SpaceBeforeBar: Rule;
public NoSpaceBeforeBar: Rule;
public SpaceAfterBar: Rule;
public NoSpaceAfterBar: Rule;
constructor() {
///
/// Common Rules
@ -360,6 +380,27 @@ namespace ts.formatting {
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// Type alias declaration
this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// template string
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// union type
this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@ -386,6 +427,11 @@ namespace ts.formatting {
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,

View File

@ -408,6 +408,7 @@ namespace ts.formatting {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
@ -429,6 +430,16 @@ namespace ts.formatting {
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.JsxElement:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.Parameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.UnionType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AwaitExpression:
return true;
}
return false;
@ -448,8 +459,6 @@ namespace ts.formatting {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:

View File

@ -0,0 +1,13 @@
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts]
type TreeNode = {
name: string;
parent: TreeNode;
}
var nodes: TreeNode[];
nodes.map(n => n.name);
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js]
var nodes;
nodes.map(function (n) { return n.name; });

View File

@ -0,0 +1,25 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts ===
type TreeNode = {
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0))
name: string;
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17))
parent: TreeNode;
>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 1, 17))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0))
}
var nodes: TreeNode[];
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0))
nodes.map(n => n.name);
>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3))
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10))
>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10))
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17))

View File

@ -0,0 +1,27 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts ===
type TreeNode = {
>TreeNode : { name: string; parent: TreeNode; }
name: string;
>name : string
parent: TreeNode;
>parent : { name: string; parent: TreeNode; }
>TreeNode : { name: string; parent: TreeNode; }
}
var nodes: TreeNode[];
>nodes : { name: string; parent: TreeNode; }[]
>TreeNode : { name: string; parent: TreeNode; }
nodes.map(n => n.name);
>nodes.map(n => n.name) : string[]
>nodes.map : <U>(callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[]
>nodes : { name: string; parent: TreeNode; }[]
>map : <U>(callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[]
>n => n.name : (n: { name: string; parent: TreeNode; }) => string
>n : { name: string; parent: TreeNode; }
>n.name : string
>n : { name: string; parent: TreeNode; }
>name : string

View File

@ -0,0 +1,18 @@
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts]
type TreeNode = {
name: string;
parent: TreeNode;
}
type TreeNodeMiddleman = {
name: string;
parent: TreeNode;
}
var nodes: TreeNodeMiddleman[];
nodes.map(n => n.name);
//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js]
var nodes;
nodes.map(function (n) { return n.name; });

View File

@ -0,0 +1,36 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts ===
type TreeNode = {
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0))
name: string;
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 17))
parent: TreeNode;
>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 1, 17))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0))
}
type TreeNodeMiddleman = {
>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1))
name: string;
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26))
parent: TreeNode;
>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 6, 17))
>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0))
}
var nodes: TreeNodeMiddleman[];
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3))
>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1))
nodes.map(n => n.name);
>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3))
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10))
>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26))
>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10))
>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26))

View File

@ -0,0 +1,38 @@
=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts ===
type TreeNode = {
>TreeNode : { name: string; parent: TreeNode; }
name: string;
>name : string
parent: TreeNode;
>parent : { name: string; parent: TreeNode; }
>TreeNode : { name: string; parent: TreeNode; }
}
type TreeNodeMiddleman = {
>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; }
name: string;
>name : string
parent: TreeNode;
>parent : { name: string; parent: TreeNode; }
>TreeNode : { name: string; parent: TreeNode; }
}
var nodes: TreeNodeMiddleman[];
>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[]
>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; }
nodes.map(n => n.name);
>nodes.map(n => n.name) : string[]
>nodes.map : <U>(callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[]
>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[]
>map : <U>(callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[]
>n => n.name : (n: { name: string; parent: { name: string; parent: TreeNode; }; }) => string
>n : { name: string; parent: { name: string; parent: TreeNode; }; }
>n.name : string
>n : { name: string; parent: { name: string; parent: TreeNode; }; }
>name : string

View File

@ -0,0 +1,7 @@
type TreeNode = {
name: string;
parent: TreeNode;
}
var nodes: TreeNode[];
nodes.map(n => n.name);

View File

@ -0,0 +1,12 @@
type TreeNode = {
name: string;
parent: TreeNode;
}
type TreeNodeMiddleman = {
name: string;
parent: TreeNode;
}
var nodes: TreeNodeMiddleman[];
nodes.map(n => n.name);

View File

@ -0,0 +1,19 @@
/// <reference path="fourslash.ts"/>
////async function asyncFunction() {/*asyncKeyword*/
//// await
/////*awaitExpressionIndent*/
//// Promise.resolve("await");/*awaitExpressionAutoformat*/
//// return await Promise.resolve("completed");/*awaitKeyword*/
////}
format.document();
goTo.marker("asyncKeyword");
verify.currentLineContentIs("async function asyncFunction() {");
goTo.marker("awaitExpressionIndent");
verify.indentationIs(8);
goTo.marker("awaitExpressionAutoformat");
verify.currentLineContentIs(' Promise.resolve("await");');
goTo.marker("awaitKeyword");
verify.currentLineContentIs(' return await Promise.resolve("completed");');

View File

@ -0,0 +1,32 @@
/// <reference path='fourslash.ts' />
////function renderElement(
//// element: Element,
//// renderNode:
////(/*funcAutoformat*/
//// node: Node/*funcParamAutoformat*/
/////*funcIndent*/
//// ) => void,
////newNode:
////new(/*constrAutoformat*/
//// name: string/*constrParamAutoformat*/
/////*constrIndent*/
////) => Node
////): void {
////}
format.document();
goTo.marker("funcAutoformat");
verify.currentLineContentIs(" (");
goTo.marker("funcParamAutoformat");
verify.currentLineContentIs(" node: Node");
goTo.marker("funcIndent");
verify.indentationIs(12);
goTo.marker("constrAutoformat");
verify.currentLineContentIs(" new (");
goTo.marker("constrParamAutoformat");
verify.currentLineContentIs(" name: string");
goTo.marker("constrIndent");
verify.indentationIs(12);

View File

@ -0,0 +1,23 @@
/// <reference path='fourslash.ts' />
////function foo(
//// first:
//// number,/*first*/
//// second: (
//// string/*second*/
//// ),
//// third:
//// (
//// boolean/*third*/
//// )
////) {
////}
format.document();
goTo.marker("first");
verify.currentLineContentIs(" number,");
goTo.marker("second");
verify.currentLineContentIs(" string");
goTo.marker("third");
verify.currentLineContentIs(" boolean");

View File

@ -0,0 +1,31 @@
/// <reference path="fourslash.ts"/>
////type Foo = {
//// (
//// call: any/*callAutoformat*/
/////*callIndent*/
//// ): void;
//// new (
//// constr: any/*constrAutoformat*/
/////*constrIndent*/
//// ): void;
//// method(
//// whatever: any/*methodAutoformat*/
/////*methodIndent*/
//// ): void;
////};
format.document();
goTo.marker("callAutoformat");
verify.currentLineContentIs(" call: any");
goTo.marker("callIndent");
verify.indentationIs(8);
goTo.marker("constrAutoformat");
verify.currentLineContentIs(" constr: any");
goTo.marker("constrIndent");
verify.indentationIs(8);
goTo.marker("methodAutoformat");
verify.currentLineContentIs(" whatever: any");
goTo.marker("methodIndent");
verify.indentationIs(8);

View File

@ -2,6 +2,10 @@
////var x = `sadasdasdasdasfegsfd
/////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `;
////var y = `1${2}/*2*/3`;
////let z= `foo`/*3*/
////let w= `bar${3}`/*4*/
////String.raw
//// `template`/*5*/
goTo.marker("1");
@ -10,4 +14,15 @@ edit.insert("\r\n"); // edit will trigger formatting - should succeeed
goTo.marker("2");
edit.insert("\r\n");
verify.indentationIs(0);
verify.currentLineContentIs("3`;")
verify.currentLineContentIs("3`;")
goTo.marker("3");
edit.insert(";");
verify.currentLineContentIs("let z = `foo`;");
goTo.marker("4");
edit.insert(";");
verify.currentLineContentIs("let w = `bar${3}`;");
goTo.marker("5");
edit.insert(";");
verify.currentLineContentIs(" `template`;");

View File

@ -0,0 +1,14 @@
/// <reference path="fourslash.ts"/>
////type Alias = /*typeKeyword*/
/////*indent*/
////number;/*autoformat*/
format.document();
goTo.marker("typeKeyword");
verify.currentLineContentIs("type Alias =");
goTo.marker("indent");
verify.indentationIs(4);
goTo.marker("autoformat");
verify.currentLineContentIs(" number;");

View File

@ -0,0 +1,14 @@
/// <reference path="fourslash.ts"/>
////type Union = number | {}/*formatOperator*/
/////*indent*/
////|string/*autoformat*/
format.document();
goTo.marker("formatOperator");
verify.currentLineContentIs("type Union = number | {}");
goTo.marker("indent");
verify.indentationIs(4);
goTo.marker("autoformat");
verify.currentLineContentIs(" | string");

View File

@ -12,6 +12,6 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): voi
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 4);
verifyIndentationAfterNewLine("4", 4);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 4);
verifyIndentationAfterNewLine("6", 4);