Merge pull request #5410 from kenhowardpdx/es6-source-order

Fixed ES6 Source Order
This commit is contained in:
Mohamed Hegazy 2015-10-27 10:24:25 -07:00
commit 6d9e7938dc
11 changed files with 182880 additions and 182760 deletions

View file

@ -164,7 +164,7 @@ var librarySourceMap = [
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
{ target: "lib.es6.d.ts", sources: ["es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
];
var libraryTargets = librarySourceMap.map(function (f) {

2
lib/lib.core.d.ts vendored
View file

@ -1225,7 +1225,7 @@ interface ArrayBuffer {
interface ArrayBufferConstructor {
prototype: ArrayBuffer;
new (byteLength: number): ArrayBuffer;
isView(arg: any): boolean;
isView(arg: any): arg is ArrayBufferView;
}
declare var ArrayBuffer: ArrayBufferConstructor;

View file

@ -1225,7 +1225,7 @@ interface ArrayBuffer {
interface ArrayBufferConstructor {
prototype: ArrayBuffer;
new (byteLength: number): ArrayBuffer;
isView(arg: any): boolean;
isView(arg: any): arg is ArrayBufferView;
}
declare var ArrayBuffer: ArrayBufferConstructor;

2
lib/lib.d.ts vendored
View file

@ -1225,7 +1225,7 @@ interface ArrayBuffer {
interface ArrayBufferConstructor {
prototype: ArrayBuffer;
new (byteLength: number): ArrayBuffer;
isView(arg: any): boolean;
isView(arg: any): arg is ArrayBufferView;
}
declare var ArrayBuffer: ArrayBufferConstructor;

2632
lib/lib.es6.d.ts vendored

File diff suppressed because it is too large Load diff

View file

@ -709,15 +709,13 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
}
Node.prototype = {
kind: kind,
pos: -1,
end: -1,
flags: 0,
parent: undefined
};
Node.prototype = { kind: kind };
return Node;
},
getSymbolConstructor: function () { return Symbol; },
@ -748,9 +746,10 @@ var ts;
})(Debug = ts.Debug || (ts.Debug = {}));
function copyListRemovingItem(item, list) {
var copiedList = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] !== item) {
copiedList.push(list[i]);
for (var _i = 0; _i < list.length; _i++) {
var e = list[_i];
if (e !== item) {
copiedList.push(e);
}
}
return copiedList;
@ -1053,7 +1052,7 @@ var ts;
};
},
watchDirectory: function (path, callback, recursive) {
return _fs.watch(path, { persisten: true, recursive: !!recursive }, function (eventName, relativeFileName) {
return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) {
if (eventName === "rename") {
callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName)));
}
@ -1263,7 +1262,7 @@ var ts;
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." },
Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." },
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." },
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." },
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
@ -1511,7 +1510,6 @@ var ts;
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." },
Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." },
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." },
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
@ -1537,6 +1535,7 @@ var ts;
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" },
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}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@ -1617,7 +1616,7 @@ var ts;
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." },
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}'." },
@ -1632,8 +1631,8 @@ var ts;
Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." },
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." },
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." },
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." },
Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." },
@ -1654,8 +1653,8 @@ var ts;
Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." },
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." },
Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
@ -3859,15 +3858,15 @@ var ts;
return node.end - node.pos;
}
ts.getFullWidth = getFullWidth;
function arrayIsEqualTo(arr1, arr2, comparer) {
if (!arr1 || !arr2) {
return arr1 === arr2;
function arrayIsEqualTo(array1, array2, equaler) {
if (!array1 || !array2) {
return array1 === array2;
}
if (arr1.length !== arr2.length) {
if (array1.length !== array2.length) {
return false;
}
for (var i = 0; i < arr1.length; ++i) {
var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i];
for (var i = 0; i < array1.length; ++i) {
var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
if (!equals) {
return false;
}
@ -5089,7 +5088,7 @@ var ts;
}
ts.nodeIsSynthesized = nodeIsSynthesized;
function createSynthesizedNode(kind, startsOnNewLine) {
var node = ts.createNode(kind);
var node = ts.createNode(kind, -1, -1);
node.startsOnNewLine = startsOnNewLine;
return node;
}
@ -5776,16 +5775,6 @@ var ts;
}
}
ts.getTypeParameterOwner = getTypeParameterOwner;
function arrayStructurallyIsEqualTo(array1, array2) {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return ts.arrayIsEqualTo(array1.sort(), array2.sort());
}
ts.arrayStructurallyIsEqualTo = arrayStructurallyIsEqualTo;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -5795,8 +5784,8 @@ var ts;
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
}
ts.getNodeConstructor = getNodeConstructor;
function createNode(kind) {
return new (getNodeConstructor(kind))();
function createNode(kind, pos, end) {
return new (getNodeConstructor(kind))(pos, end);
}
ts.createNode = createNode;
function visitNode(cbNode, node) {
@ -6525,13 +6514,10 @@ var ts;
}
function createNode(kind, pos) {
nodeCount++;
var node = new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))();
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
node.pos = pos;
node.end = pos;
return node;
return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -8084,17 +8070,32 @@ var ts;
}
function parseJsxElementOrSelfClosingElement(inExpressionContext) {
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
var result;
if (opening.kind === 235) {
var node = createNode(233, opening.pos);
node.openingElement = opening;
node.children = parseJsxChildren(node.openingElement.tagName);
node.closingElement = parseJsxClosingElement(inExpressionContext);
return finishNode(node);
result = finishNode(node);
}
else {
ts.Debug.assert(opening.kind === 234);
return opening;
result = opening;
}
if (inExpressionContext && token === 25) {
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); });
if (invalidElement) {
parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
var badNode = createNode(181, result.pos);
badNode.end = invalidElement.end;
badNode.left = result;
badNode.right = invalidElement;
badNode.operatorToken = createMissingNode(24, false, undefined);
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
return badNode;
}
}
return result;
}
function parseJsxText() {
var node = createNode(236, scanner.getStartPos());
@ -12632,22 +12633,27 @@ var ts;
}
return type.resolvedBaseConstructorType;
}
function hasClassBaseType(type) {
return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32); });
}
function getBaseTypes(type) {
var isClass = type.symbol.flags & 32;
var isInterface = type.symbol.flags & 64;
if (!type.resolvedBaseTypes) {
if (type.symbol.flags & 32) {
if (!isClass && !isInterface) {
ts.Debug.fail("type must be class or interface");
}
if (isClass) {
resolveBaseTypesOfClass(type);
}
else if (type.symbol.flags & 64) {
if (isInterface) {
resolveBaseTypesOfInterface(type);
}
else {
ts.Debug.fail("type must be class or interface");
}
}
return type.resolvedBaseTypes;
}
function resolveBaseTypesOfClass(type) {
type.resolvedBaseTypes = emptyArray;
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
var baseContructorType = getBaseConstructorTypeOfClass(type);
if (!(baseContructorType.flags & 80896)) {
return;
@ -12676,10 +12682,15 @@ var ts;
error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1));
return;
}
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
function resolveBaseTypesOfInterface(type) {
type.resolvedBaseTypes = [];
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) {
@ -12689,8 +12700,13 @@ var ts;
if (baseType !== unknownType) {
if (getTargetType(baseType).flags & (1024 | 2048)) {
if (type !== baseType && !hasBaseType(baseType, type)) {
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
else {
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1));
}
@ -12987,7 +13003,7 @@ var ts;
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
function getDefaultConstructSignatures(classType) {
if (!getBaseTypes(classType).length) {
if (!hasClassBaseType(classType)) {
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
}
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
@ -13388,7 +13404,9 @@ var ts;
function getSignatureFromDeclaration(declaration) {
var links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
var classType = declaration.kind === 144 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined;
var classType = declaration.kind === 144 ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
: undefined;
var typeParameters = classType ? classType.localTypeParameters :
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
var parameters = [];
@ -14352,7 +14370,7 @@ var ts;
var apparentType = getApparentType(source);
if (apparentType.flags & (80896 | 32768) && target.flags & 80896) {
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) {
if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) {
errorInfo = saveErrorInfo;
return result;
}
@ -14371,7 +14389,7 @@ var ts;
return result;
}
}
return objectTypeRelatedTo(source, target, false);
return objectTypeRelatedTo(source, source, target, false);
}
if (source.flags & 512 && target.flags & 512) {
return typeParameterIdenticalTo(source, target);
@ -14393,20 +14411,19 @@ var ts;
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & 49152) {
else if (type.flags & 49152) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
}
return false;
}
return true;
}
function hasExcessProperties(source, target, reportErrors) {
if (someConstituentTypeHasKind(target, 80896)) {
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
@ -14418,6 +14435,8 @@ var ts;
}
}
}
return false;
}
function eachTypeRelatedToSomeType(source, target) {
var result = -1;
var sourceTypes = source.types;
@ -14505,11 +14524,11 @@ var ts;
}
return isIdenticalTo(source.constraint, target.constraint);
}
function objectTypeRelatedTo(source, target, reportErrors) {
function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) {
if (overflow) {
return 0;
}
var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id;
var related = relation[id];
if (related !== undefined) {
if (!elaborateErrors || (related === 3)) {
@ -14533,13 +14552,13 @@ var ts;
maybeStack = [];
expandingFlags = 0;
}
sourceStack[depth] = source;
sourceStack[depth] = apparentSource;
targetStack[depth] = target;
maybeStack[depth] = {};
maybeStack[depth][id] = 1;
depth++;
var saveExpandingFlags = expandingFlags;
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth))
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth))
expandingFlags |= 1;
if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth))
expandingFlags |= 2;
@ -14548,15 +14567,15 @@ var ts;
result = 1;
}
else {
result = propertiesRelatedTo(source, target, reportErrors);
result = propertiesRelatedTo(apparentSource, target, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 0, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 0, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 1, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 1, reportErrors);
if (result) {
result &= stringIndexTypesRelatedTo(source, target, reportErrors);
result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
if (result) {
result &= numberIndexTypesRelatedTo(source, target, reportErrors);
result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
}
}
}
@ -14829,12 +14848,15 @@ var ts;
}
return result;
}
function stringIndexTypesRelatedTo(source, target, reportErrors) {
function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(0, source, target);
}
var targetType = getIndexTypeOfType(target, 0);
if (targetType && !(targetType.flags & 1)) {
if (targetType) {
if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) {
return -1;
}
var sourceType = getIndexTypeOfType(source, 0);
if (!sourceType) {
if (reportErrors) {
@ -14853,12 +14875,15 @@ var ts;
}
return -1;
}
function numberIndexTypesRelatedTo(source, target, reportErrors) {
function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(1, source, target);
}
var targetType = getIndexTypeOfType(target, 1);
if (targetType && !(targetType.flags & 1)) {
if (targetType) {
if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) {
return -1;
}
var sourceStringType = getIndexTypeOfType(source, 0);
var sourceNumberType = getIndexTypeOfType(source, 1);
if (!(sourceStringType || sourceNumberType)) {
@ -14966,11 +14991,10 @@ var ts;
}
source = getErasedSignature(source);
target = getErasedSignature(target);
var sourceLen = source.parameters.length;
var targetLen = target.parameters.length;
for (var i = 0; i < targetLen; i++) {
var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var related = compareTypes(s, t);
if (!related) {
return 0;
@ -14982,6 +15006,9 @@ var ts;
}
return result;
}
function isRestParameterIndex(signature, parameterIndex) {
return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1;
}
function isSupertypeOfEach(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
@ -15920,8 +15947,9 @@ var ts;
if (indexOfParameter < len) {
return getTypeAtPosition(contextualSignature, indexOfParameter);
}
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
if (funcHasRestParameters &&
indexOfParameter === (func.parameters.length - 1) &&
isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
@ -16451,8 +16479,6 @@ var ts;
case 234:
checkJsxSelfClosingElement(child);
break;
default:
ts.Debug.assert(child.kind === 236);
}
}
return jsxElementType || anyType;
@ -17041,7 +17067,7 @@ var ts;
return false;
}
if (spreadArgIndex >= 0) {
return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1;
return isRestParameterIndex(signature, spreadArgIndex);
}
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
return false;
@ -17187,41 +17213,41 @@ var ts;
}
}
function getEffectiveDecoratorFirstArgumentType(node) {
switch (node.kind) {
case 214:
case 186:
if (node.kind === 214) {
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
case 138:
}
if (node.kind === 138) {
node = node.parent;
if (node.kind === 144) {
var classSymbol_1 = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol_1);
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
}
case 141:
case 143:
case 145:
case 146:
}
if (node.kind === 141 ||
node.kind === 143 ||
node.kind === 145 ||
node.kind === 146) {
return getParentTypeOfClassElement(node);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
function getEffectiveDecoratorSecondArgumentType(node) {
switch (node.kind) {
case 214:
if (node.kind === 214) {
ts.Debug.fail("Class decorators should not have a second synthetic argument.");
return unknownType;
case 138:
}
if (node.kind === 138) {
node = node.parent;
if (node.kind === 144) {
return anyType;
}
case 141:
case 143:
case 145:
case 146:
}
if (node.kind === 141 ||
node.kind === 143 ||
node.kind === 145 ||
node.kind === 146) {
var element = node;
switch (element.name.kind) {
case 69:
@ -17240,31 +17266,31 @@ var ts;
ts.Debug.fail("Unsupported property name.");
return unknownType;
}
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
function getEffectiveDecoratorThirdArgumentType(node) {
switch (node.kind) {
case 214:
if (node.kind === 214) {
ts.Debug.fail("Class decorators should not have a third synthetic argument.");
return unknownType;
case 138:
}
if (node.kind === 138) {
return numberType;
case 141:
}
if (node.kind === 141) {
ts.Debug.fail("Property decorators should not have a third synthetic argument.");
return unknownType;
case 143:
case 145:
case 146:
}
if (node.kind === 143 ||
node.kind === 145 ||
node.kind === 146) {
var propertyType = getTypeOfNode(node);
return createTypedPropertyDescriptorType(propertyType);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
function getEffectiveDecoratorArgumentType(node, argIndex) {
if (argIndex === 0) {
return getEffectiveDecoratorFirstArgumentType(node.parent);
@ -17639,7 +17665,7 @@ var ts;
var contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
var parameter = ts.lastOrUndefined(signature.parameters);
var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
@ -18907,7 +18933,10 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedNodeFlags(n);
if (n.parent.kind !== 215 && ts.isInAmbientContext(n)) {
if (n.parent.kind !== 215 &&
n.parent.kind !== 214 &&
n.parent.kind !== 186 &&
ts.isInAmbientContext(n)) {
if (!(flags & 2)) {
flags |= 1;
}
@ -20102,9 +20131,6 @@ var ts;
grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkClassLikeDeclaration(node);
if (getSymbolOfNode(node).flags & 64 && !ts.isInAmbientContext(node)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
}
ts.forEach(node.members, checkSourceElement);
}
function checkClassLikeDeclaration(node) {
@ -20324,15 +20350,6 @@ var ts;
checkIndexConstraints(type);
}
}
if (symbol && symbol.declarations) {
for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
var declaration = _c[_b];
if (declaration.kind === 214 && !ts.isInAmbientContext(declaration)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
break;
}
}
}
}
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
@ -25376,7 +25393,8 @@ var ts;
write(".");
}
}
else if (modulekind !== 5) {
else {
if (modulekind !== 5) {
var declaration = resolver.getReferencedImportDeclaration(node);
if (declaration) {
if (declaration.kind === 223) {
@ -25398,12 +25416,15 @@ var ts;
return;
}
}
declaration = resolver.getReferencedNestedRedeclaration(node);
}
if (languageVersion !== 2) {
var declaration = resolver.getReferencedNestedRedeclaration(node);
if (declaration) {
write(getGeneratedNameForNode(declaration.name));
return;
}
}
}
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
@ -26142,7 +26163,7 @@ var ts;
return isSourceFileLevelDeclarationInSystemJsModule(node, false);
}
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) {
if (!node || !isCurrentFileSystemExternalModule()) {
return false;
}
var current = node;
@ -30625,7 +30646,7 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
@ -30638,7 +30659,7 @@ var ts;
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
if (options.module === 5 && languageVersion < 2) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
}
if (options.outDir ||
options.sourceRoot ||
@ -30752,9 +30773,9 @@ var ts;
"es6": 5,
"es2015": 5
},
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015
},
{
name: "newLine",
@ -30884,9 +30905,9 @@ var ts;
"es6": 2,
"es2015": 2
},
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental,
paramType: ts.Diagnostics.VERSION,
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015
},
{
name: "version",
@ -31053,56 +31074,12 @@ var ts;
}
ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
function parseJsonConfigFileContent(json, host, basePath) {
var errors = [];
var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors;
return {
options: getCompilerOptions(),
options: options,
fileNames: getFileNames(),
errors: errors
};
function getCompilerOptions() {
var options = {};
var optionNameMap = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name] = option;
});
var jsonOptions = json["compilerOptions"];
if (jsonOptions) {
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
}
return options;
}
function getFileNames() {
var fileNames = [];
if (ts.hasProperty(json, "files")) {
@ -31138,6 +31115,49 @@ var ts;
}
}
ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
function convertCompilerOptionsFromJson(jsonOptions, basePath) {
var options = {};
var errors = [];
if (!jsonOptions) {
return { options: options, errors: errors };
}
var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; });
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
return { options: options, errors: errors };
}
ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -31260,6 +31280,8 @@ var ts;
var hostGetSourceFile;
var timerHandleForRecompilation;
var timerHandleForDirectoryChanges;
var cachedExistingFiles;
var hostFileExists;
if (commandLine.options.locale) {
if (!isJSONSupported()) {
reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
@ -31354,7 +31376,10 @@ var ts;
compilerHost = ts.createCompilerHost(compilerOptions);
hostGetSourceFile = compilerHost.getSourceFile;
compilerHost.getSourceFile = getSourceFile;
hostFileExists = compilerHost.fileExists;
compilerHost.fileExists = cachedFileExists;
}
cachedExistingFiles = {};
var compileResult = compile(rootFileNames, compilerOptions, compilerHost);
if (!compilerOptions.watch) {
return ts.sys.exit(compileResult.exitStatus);
@ -31362,6 +31387,12 @@ var ts;
setCachedProgram(compileResult.program);
reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes));
}
function cachedFileExists(fileName) {
if (ts.hasProperty(cachedExistingFiles, fileName)) {
return cachedExistingFiles[fileName];
}
return cachedExistingFiles[fileName] = hostFileExists(fileName);
}
function getSourceFile(fileName, languageVersion, onError) {
if (cachedProgram) {
var sourceFile_1 = cachedProgram.getSourceFile(fileName);
@ -31421,7 +31452,7 @@ var ts;
var parsedCommandLine = parseConfigFile();
var newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName);
var canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
if (!ts.arrayStructurallyIsEqualTo(newFileNames, canonicalRootFileNames)) {
if (!ts.arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) {
setCachedProgram(undefined);
startTimerForRecompilation();
}
@ -31562,7 +31593,7 @@ var ts;
}
function writeConfigFile(options, fileNames) {
var currentDirectory = ts.sys.getCurrentDirectory();
var file = ts.combinePaths(currentDirectory, "tsconfig.json");
var file = ts.normalizePath(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));
}

View file

@ -709,15 +709,13 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
}
Node.prototype = {
kind: kind,
pos: -1,
end: -1,
flags: 0,
parent: undefined
};
Node.prototype = { kind: kind };
return Node;
},
getSymbolConstructor: function () { return Symbol; },
@ -748,9 +746,10 @@ var ts;
})(Debug = ts.Debug || (ts.Debug = {}));
function copyListRemovingItem(item, list) {
var copiedList = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] !== item) {
copiedList.push(list[i]);
for (var _i = 0; _i < list.length; _i++) {
var e = list[_i];
if (e !== item) {
copiedList.push(e);
}
}
return copiedList;
@ -1053,7 +1052,7 @@ var ts;
};
},
watchDirectory: function (path, callback, recursive) {
return _fs.watch(path, { persisten: true, recursive: !!recursive }, function (eventName, relativeFileName) {
return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) {
if (eventName === "rename") {
callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName)));
}
@ -1263,7 +1262,7 @@ var ts;
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." },
Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." },
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." },
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." },
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
@ -1511,7 +1510,6 @@ var ts;
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." },
Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." },
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." },
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
@ -1537,6 +1535,7 @@ var ts;
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" },
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}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@ -1617,7 +1616,7 @@ var ts;
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." },
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}'." },
@ -1632,8 +1631,8 @@ var ts;
Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." },
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." },
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." },
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." },
Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." },
@ -1654,8 +1653,8 @@ var ts;
Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." },
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." },
Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
@ -3156,9 +3155,9 @@ var ts;
"es6": 5,
"es2015": 5
},
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015
},
{
name: "newLine",
@ -3288,9 +3287,9 @@ var ts;
"es6": 2,
"es2015": 2
},
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental,
paramType: ts.Diagnostics.VERSION,
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015
},
{
name: "version",
@ -3457,56 +3456,12 @@ var ts;
}
ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
function parseJsonConfigFileContent(json, host, basePath) {
var errors = [];
var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors;
return {
options: getCompilerOptions(),
options: options,
fileNames: getFileNames(),
errors: errors
};
function getCompilerOptions() {
var options = {};
var optionNameMap = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name] = option;
});
var jsonOptions = json["compilerOptions"];
if (jsonOptions) {
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
}
return options;
}
function getFileNames() {
var fileNames = [];
if (ts.hasProperty(json, "files")) {
@ -3542,6 +3497,49 @@ var ts;
}
}
ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
function convertCompilerOptionsFromJson(jsonOptions, basePath) {
var options = {};
var errors = [];
if (!jsonOptions) {
return { options: options, errors: errors };
}
var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; });
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
return { options: options, errors: errors };
}
ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -3592,15 +3590,15 @@ var ts;
return node.end - node.pos;
}
ts.getFullWidth = getFullWidth;
function arrayIsEqualTo(arr1, arr2, comparer) {
if (!arr1 || !arr2) {
return arr1 === arr2;
function arrayIsEqualTo(array1, array2, equaler) {
if (!array1 || !array2) {
return array1 === array2;
}
if (arr1.length !== arr2.length) {
if (array1.length !== array2.length) {
return false;
}
for (var i = 0; i < arr1.length; ++i) {
var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i];
for (var i = 0; i < array1.length; ++i) {
var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
if (!equals) {
return false;
}
@ -4822,7 +4820,7 @@ var ts;
}
ts.nodeIsSynthesized = nodeIsSynthesized;
function createSynthesizedNode(kind, startsOnNewLine) {
var node = ts.createNode(kind);
var node = ts.createNode(kind, -1, -1);
node.startsOnNewLine = startsOnNewLine;
return node;
}
@ -5509,16 +5507,6 @@ var ts;
}
}
ts.getTypeParameterOwner = getTypeParameterOwner;
function arrayStructurallyIsEqualTo(array1, array2) {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return ts.arrayIsEqualTo(array1.sort(), array2.sort());
}
ts.arrayStructurallyIsEqualTo = arrayStructurallyIsEqualTo;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -5528,8 +5516,8 @@ var ts;
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
}
ts.getNodeConstructor = getNodeConstructor;
function createNode(kind) {
return new (getNodeConstructor(kind))();
function createNode(kind, pos, end) {
return new (getNodeConstructor(kind))(pos, end);
}
ts.createNode = createNode;
function visitNode(cbNode, node) {
@ -6258,13 +6246,10 @@ var ts;
}
function createNode(kind, pos) {
nodeCount++;
var node = new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))();
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
node.pos = pos;
node.end = pos;
return node;
return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -7817,17 +7802,32 @@ var ts;
}
function parseJsxElementOrSelfClosingElement(inExpressionContext) {
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
var result;
if (opening.kind === 235) {
var node = createNode(233, opening.pos);
node.openingElement = opening;
node.children = parseJsxChildren(node.openingElement.tagName);
node.closingElement = parseJsxClosingElement(inExpressionContext);
return finishNode(node);
result = finishNode(node);
}
else {
ts.Debug.assert(opening.kind === 234);
return opening;
result = opening;
}
if (inExpressionContext && token === 25) {
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); });
if (invalidElement) {
parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
var badNode = createNode(181, result.pos);
badNode.end = invalidElement.end;
badNode.left = result;
badNode.right = invalidElement;
badNode.operatorToken = createMissingNode(24, false, undefined);
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
return badNode;
}
}
return result;
}
function parseJsxText() {
var node = createNode(236, scanner.getStartPos());
@ -13095,22 +13095,27 @@ var ts;
}
return type.resolvedBaseConstructorType;
}
function hasClassBaseType(type) {
return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32); });
}
function getBaseTypes(type) {
var isClass = type.symbol.flags & 32;
var isInterface = type.symbol.flags & 64;
if (!type.resolvedBaseTypes) {
if (type.symbol.flags & 32) {
if (!isClass && !isInterface) {
ts.Debug.fail("type must be class or interface");
}
if (isClass) {
resolveBaseTypesOfClass(type);
}
else if (type.symbol.flags & 64) {
if (isInterface) {
resolveBaseTypesOfInterface(type);
}
else {
ts.Debug.fail("type must be class or interface");
}
}
return type.resolvedBaseTypes;
}
function resolveBaseTypesOfClass(type) {
type.resolvedBaseTypes = emptyArray;
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
var baseContructorType = getBaseConstructorTypeOfClass(type);
if (!(baseContructorType.flags & 80896)) {
return;
@ -13139,10 +13144,15 @@ var ts;
error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1));
return;
}
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
function resolveBaseTypesOfInterface(type) {
type.resolvedBaseTypes = [];
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) {
@ -13152,8 +13162,13 @@ var ts;
if (baseType !== unknownType) {
if (getTargetType(baseType).flags & (1024 | 2048)) {
if (type !== baseType && !hasBaseType(baseType, type)) {
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
else {
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1));
}
@ -13450,7 +13465,7 @@ var ts;
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
function getDefaultConstructSignatures(classType) {
if (!getBaseTypes(classType).length) {
if (!hasClassBaseType(classType)) {
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
}
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
@ -13851,7 +13866,9 @@ var ts;
function getSignatureFromDeclaration(declaration) {
var links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
var classType = declaration.kind === 144 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined;
var classType = declaration.kind === 144 ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
: undefined;
var typeParameters = classType ? classType.localTypeParameters :
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
var parameters = [];
@ -14815,7 +14832,7 @@ var ts;
var apparentType = getApparentType(source);
if (apparentType.flags & (80896 | 32768) && target.flags & 80896) {
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) {
if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) {
errorInfo = saveErrorInfo;
return result;
}
@ -14834,7 +14851,7 @@ var ts;
return result;
}
}
return objectTypeRelatedTo(source, target, false);
return objectTypeRelatedTo(source, source, target, false);
}
if (source.flags & 512 && target.flags & 512) {
return typeParameterIdenticalTo(source, target);
@ -14856,20 +14873,19 @@ var ts;
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & 49152) {
else if (type.flags & 49152) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
}
return false;
}
return true;
}
function hasExcessProperties(source, target, reportErrors) {
if (someConstituentTypeHasKind(target, 80896)) {
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
@ -14881,6 +14897,8 @@ var ts;
}
}
}
return false;
}
function eachTypeRelatedToSomeType(source, target) {
var result = -1;
var sourceTypes = source.types;
@ -14968,11 +14986,11 @@ var ts;
}
return isIdenticalTo(source.constraint, target.constraint);
}
function objectTypeRelatedTo(source, target, reportErrors) {
function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) {
if (overflow) {
return 0;
}
var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id;
var related = relation[id];
if (related !== undefined) {
if (!elaborateErrors || (related === 3)) {
@ -14996,13 +15014,13 @@ var ts;
maybeStack = [];
expandingFlags = 0;
}
sourceStack[depth] = source;
sourceStack[depth] = apparentSource;
targetStack[depth] = target;
maybeStack[depth] = {};
maybeStack[depth][id] = 1;
depth++;
var saveExpandingFlags = expandingFlags;
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth))
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth))
expandingFlags |= 1;
if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth))
expandingFlags |= 2;
@ -15011,15 +15029,15 @@ var ts;
result = 1;
}
else {
result = propertiesRelatedTo(source, target, reportErrors);
result = propertiesRelatedTo(apparentSource, target, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 0, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 0, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 1, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 1, reportErrors);
if (result) {
result &= stringIndexTypesRelatedTo(source, target, reportErrors);
result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
if (result) {
result &= numberIndexTypesRelatedTo(source, target, reportErrors);
result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
}
}
}
@ -15292,12 +15310,15 @@ var ts;
}
return result;
}
function stringIndexTypesRelatedTo(source, target, reportErrors) {
function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(0, source, target);
}
var targetType = getIndexTypeOfType(target, 0);
if (targetType && !(targetType.flags & 1)) {
if (targetType) {
if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) {
return -1;
}
var sourceType = getIndexTypeOfType(source, 0);
if (!sourceType) {
if (reportErrors) {
@ -15316,12 +15337,15 @@ var ts;
}
return -1;
}
function numberIndexTypesRelatedTo(source, target, reportErrors) {
function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(1, source, target);
}
var targetType = getIndexTypeOfType(target, 1);
if (targetType && !(targetType.flags & 1)) {
if (targetType) {
if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) {
return -1;
}
var sourceStringType = getIndexTypeOfType(source, 0);
var sourceNumberType = getIndexTypeOfType(source, 1);
if (!(sourceStringType || sourceNumberType)) {
@ -15429,11 +15453,10 @@ var ts;
}
source = getErasedSignature(source);
target = getErasedSignature(target);
var sourceLen = source.parameters.length;
var targetLen = target.parameters.length;
for (var i = 0; i < targetLen; i++) {
var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var related = compareTypes(s, t);
if (!related) {
return 0;
@ -15445,6 +15468,9 @@ var ts;
}
return result;
}
function isRestParameterIndex(signature, parameterIndex) {
return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1;
}
function isSupertypeOfEach(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
@ -16383,8 +16409,9 @@ var ts;
if (indexOfParameter < len) {
return getTypeAtPosition(contextualSignature, indexOfParameter);
}
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
if (funcHasRestParameters &&
indexOfParameter === (func.parameters.length - 1) &&
isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
@ -16914,8 +16941,6 @@ var ts;
case 234:
checkJsxSelfClosingElement(child);
break;
default:
ts.Debug.assert(child.kind === 236);
}
}
return jsxElementType || anyType;
@ -17504,7 +17529,7 @@ var ts;
return false;
}
if (spreadArgIndex >= 0) {
return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1;
return isRestParameterIndex(signature, spreadArgIndex);
}
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
return false;
@ -17650,41 +17675,41 @@ var ts;
}
}
function getEffectiveDecoratorFirstArgumentType(node) {
switch (node.kind) {
case 214:
case 186:
if (node.kind === 214) {
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
case 138:
}
if (node.kind === 138) {
node = node.parent;
if (node.kind === 144) {
var classSymbol_1 = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol_1);
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
}
case 141:
case 143:
case 145:
case 146:
}
if (node.kind === 141 ||
node.kind === 143 ||
node.kind === 145 ||
node.kind === 146) {
return getParentTypeOfClassElement(node);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
function getEffectiveDecoratorSecondArgumentType(node) {
switch (node.kind) {
case 214:
if (node.kind === 214) {
ts.Debug.fail("Class decorators should not have a second synthetic argument.");
return unknownType;
case 138:
}
if (node.kind === 138) {
node = node.parent;
if (node.kind === 144) {
return anyType;
}
case 141:
case 143:
case 145:
case 146:
}
if (node.kind === 141 ||
node.kind === 143 ||
node.kind === 145 ||
node.kind === 146) {
var element = node;
switch (element.name.kind) {
case 69:
@ -17703,31 +17728,31 @@ var ts;
ts.Debug.fail("Unsupported property name.");
return unknownType;
}
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
function getEffectiveDecoratorThirdArgumentType(node) {
switch (node.kind) {
case 214:
if (node.kind === 214) {
ts.Debug.fail("Class decorators should not have a third synthetic argument.");
return unknownType;
case 138:
}
if (node.kind === 138) {
return numberType;
case 141:
}
if (node.kind === 141) {
ts.Debug.fail("Property decorators should not have a third synthetic argument.");
return unknownType;
case 143:
case 145:
case 146:
}
if (node.kind === 143 ||
node.kind === 145 ||
node.kind === 146) {
var propertyType = getTypeOfNode(node);
return createTypedPropertyDescriptorType(propertyType);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
function getEffectiveDecoratorArgumentType(node, argIndex) {
if (argIndex === 0) {
return getEffectiveDecoratorFirstArgumentType(node.parent);
@ -18102,7 +18127,7 @@ var ts;
var contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
var parameter = ts.lastOrUndefined(signature.parameters);
var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
@ -19370,7 +19395,10 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedNodeFlags(n);
if (n.parent.kind !== 215 && ts.isInAmbientContext(n)) {
if (n.parent.kind !== 215 &&
n.parent.kind !== 214 &&
n.parent.kind !== 186 &&
ts.isInAmbientContext(n)) {
if (!(flags & 2)) {
flags |= 1;
}
@ -20565,9 +20593,6 @@ var ts;
grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkClassLikeDeclaration(node);
if (getSymbolOfNode(node).flags & 64 && !ts.isInAmbientContext(node)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
}
ts.forEach(node.members, checkSourceElement);
}
function checkClassLikeDeclaration(node) {
@ -20787,15 +20812,6 @@ var ts;
checkIndexConstraints(type);
}
}
if (symbol && symbol.declarations) {
for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
var declaration = _c[_b];
if (declaration.kind === 214 && !ts.isInAmbientContext(declaration)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
break;
}
}
}
}
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
@ -25839,7 +25855,8 @@ var ts;
write(".");
}
}
else if (modulekind !== 5) {
else {
if (modulekind !== 5) {
var declaration = resolver.getReferencedImportDeclaration(node);
if (declaration) {
if (declaration.kind === 223) {
@ -25861,12 +25878,15 @@ var ts;
return;
}
}
declaration = resolver.getReferencedNestedRedeclaration(node);
}
if (languageVersion !== 2) {
var declaration = resolver.getReferencedNestedRedeclaration(node);
if (declaration) {
write(getGeneratedNameForNode(declaration.name));
return;
}
}
}
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
@ -26605,7 +26625,7 @@ var ts;
return isSourceFileLevelDeclarationInSystemJsModule(node, false);
}
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) {
if (!node || !isCurrentFileSystemExternalModule()) {
return false;
}
var current = node;
@ -31088,7 +31108,7 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
@ -31101,7 +31121,7 @@ var ts;
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
if (options.module === 5 && languageVersion < 2) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
}
if (options.outDir ||
options.sourceRoot ||
@ -35145,7 +35165,7 @@ var ts;
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
if (isTokenInRange) {
var rangeHasError = rangeContainsError(currentTokenInfo.token);
var prevStartLine = previousRangeStartLine;
var savePreviousRange = previousRange;
lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
if (rangeHasError) {
indentToken = false;
@ -35155,7 +35175,8 @@ var ts;
indentToken = lineAdded;
}
else {
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine;
var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
}
}
}
@ -35920,9 +35941,7 @@ var ts;
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new (ts.getNodeConstructor(kind))();
node.pos = pos;
node.end = end;
var node = new (ts.getNodeConstructor(kind))(pos, end);
node.flags = flags;
node.parent = parent;
return node;
@ -41268,14 +41287,14 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
}
var proto = kind === 248 ? new SourceFileObject() : new NodeObject();
proto.kind = kind;
proto.pos = -1;
proto.end = -1;
proto.flags = 0;
proto.parent = undefined;
Node.prototype = proto;
return Node;
},
@ -42687,7 +42706,7 @@ var ts;
var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error;
var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); }));
var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); }));
if (!ts.arrayStructurallyIsEqualTo(currentRootFiles, newRootFiles)) {
if (!ts.arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) {
this.updateConfiguredProject(project);
this.updateProjectStructure();
}
@ -43254,11 +43273,15 @@ var ts;
if (info.isOpen) {
if (this.openFileRoots.indexOf(info) >= 0) {
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
if (info.defaultProject && !info.defaultProject.isConfiguredProject()) {
this.removeProject(info.defaultProject);
}
}
if (this.openFilesReferenced.indexOf(info) >= 0) {
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
}
this.openFileRootsConfigured.push(info);
info.defaultProject = project;
}
}
project.addRoot(info);

13
lib/typescript.d.ts vendored
View file

@ -328,6 +328,7 @@ declare namespace ts {
FirstNode = 135,
}
const enum NodeFlags {
None = 0,
Export = 1,
Ambient = 2,
Public = 16,
@ -954,7 +955,7 @@ declare namespace ts {
getSourceFile(fileName: string): SourceFile;
getCurrentDirectory(): string;
}
interface ParseConfigHost extends ModuleResolutionHost {
interface ParseConfigHost {
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
}
interface WriteFileCallback {
@ -1521,11 +1522,10 @@ declare namespace ts {
*/
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function arrayStructurallyIsEqualTo<T>(array1: Array<T>, array2: Array<T>): boolean;
}
declare namespace ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
@ -1564,10 +1564,15 @@ declare namespace ts {
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param host Instance of ParseConfigHost used to enumerate files in folder.
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine;
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): {
options: CompilerOptions;
errors: Diagnostic[];
};
}
declare namespace ts {
/** The version of the language service API */

View file

@ -349,6 +349,7 @@ var ts;
})(ts.SyntaxKind || (ts.SyntaxKind = {}));
var SyntaxKind = ts.SyntaxKind;
(function (NodeFlags) {
NodeFlags[NodeFlags["None"] = 0] = "None";
NodeFlags[NodeFlags["Export"] = 1] = "Export";
NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient";
NodeFlags[NodeFlags["Public"] = 16] = "Public";
@ -1567,15 +1568,13 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
}
Node.prototype = {
kind: kind,
pos: -1,
end: -1,
flags: 0,
parent: undefined
};
Node.prototype = { kind: kind };
return Node;
},
getSymbolConstructor: function () { return Symbol; },
@ -1613,9 +1612,10 @@ var ts;
})(Debug = ts.Debug || (ts.Debug = {}));
function copyListRemovingItem(item, list) {
var copiedList = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] !== item) {
copiedList.push(list[i]);
for (var _i = 0; _i < list.length; _i++) {
var e = list[_i];
if (e !== item) {
copiedList.push(e);
}
}
return copiedList;
@ -1959,7 +1959,7 @@ var ts;
watchDirectory: function (path, callback, recursive) {
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
return _fs.watch(path, { persisten: true, recursive: !!recursive }, function (eventName, relativeFileName) {
return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) {
// In watchDirectory we only care about adding and removing files (when event name is
// "rename"); changes made within files are handled by corresponding fileWatchers (when
// event name is "change")
@ -2178,7 +2178,7 @@ var ts;
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." },
Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." },
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." },
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." },
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
@ -2426,7 +2426,6 @@ var ts;
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." },
Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." },
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." },
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
@ -2452,6 +2451,7 @@ var ts;
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" },
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}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@ -2532,7 +2532,7 @@ var ts;
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." },
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}'." },
@ -2547,8 +2547,8 @@ var ts;
Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." },
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." },
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." },
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." },
Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." },
@ -2569,8 +2569,8 @@ var ts;
Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." },
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." },
Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
@ -5173,15 +5173,15 @@ var ts;
return node.end - node.pos;
}
ts.getFullWidth = getFullWidth;
function arrayIsEqualTo(arr1, arr2, comparer) {
if (!arr1 || !arr2) {
return arr1 === arr2;
function arrayIsEqualTo(array1, array2, equaler) {
if (!array1 || !array2) {
return array1 === array2;
}
if (arr1.length !== arr2.length) {
if (array1.length !== array2.length) {
return false;
}
for (var i = 0; i < arr1.length; ++i) {
var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i];
for (var i = 0; i < array1.length; ++i) {
var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
if (!equals) {
return false;
}
@ -6539,7 +6539,7 @@ var ts;
}
ts.nodeIsSynthesized = nodeIsSynthesized;
function createSynthesizedNode(kind, startsOnNewLine) {
var node = ts.createNode(kind);
var node = ts.createNode(kind, /* pos */ -1, /* end */ -1);
node.startsOnNewLine = startsOnNewLine;
return node;
}
@ -7372,16 +7372,6 @@ var ts;
}
}
ts.getTypeParameterOwner = getTypeParameterOwner;
function arrayStructurallyIsEqualTo(array1, array2) {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return ts.arrayIsEqualTo(array1.sort(), array2.sort());
}
ts.arrayStructurallyIsEqualTo = arrayStructurallyIsEqualTo;
})(ts || (ts = {}));
/// <reference path="scanner.ts"/>
/// <reference path="utilities.ts"/>
@ -7393,8 +7383,8 @@ var ts;
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
}
ts.getNodeConstructor = getNodeConstructor;
function createNode(kind) {
return new (getNodeConstructor(kind))();
function createNode(kind, pos, end) {
return new (getNodeConstructor(kind))(pos, end);
}
ts.createNode = createNode;
function visitNode(cbNode, node) {
@ -8284,13 +8274,10 @@ var ts;
}
function createNode(kind, pos) {
nodeCount++;
var node = new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))();
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
node.pos = pos;
node.end = pos;
return node;
return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -10432,18 +10419,40 @@ var ts;
}
function parseJsxElementOrSelfClosingElement(inExpressionContext) {
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
var result;
if (opening.kind === 235 /* JsxOpeningElement */) {
var node = createNode(233 /* JsxElement */, opening.pos);
node.openingElement = opening;
node.children = parseJsxChildren(node.openingElement.tagName);
node.closingElement = parseJsxClosingElement(inExpressionContext);
return finishNode(node);
result = finishNode(node);
}
else {
ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */);
// Nothing else to do for self-closing elements
return opening;
result = opening;
}
// If the user writes the invalid code '<div></div><div></div>' in an expression context (i.e. not wrapped in
// an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag
// as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX
// element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter
// does less damage and we can report a better error.
// Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios
// of one sort or another.
if (inExpressionContext && token === 25 /* LessThanToken */) {
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); });
if (invalidElement) {
parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
var badNode = createNode(181 /* BinaryExpression */, result.pos);
badNode.end = invalidElement.end;
badNode.left = result;
badNode.right = invalidElement;
badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined);
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
return badNode;
}
}
return result;
}
function parseJsxText() {
var node = createNode(236 /* JsxText */, scanner.getStartPos());
@ -15811,22 +15820,27 @@ var ts;
}
return type.resolvedBaseConstructorType;
}
function hasClassBaseType(type) {
return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); });
}
function getBaseTypes(type) {
var isClass = type.symbol.flags & 32 /* Class */;
var isInterface = type.symbol.flags & 64 /* Interface */;
if (!type.resolvedBaseTypes) {
if (type.symbol.flags & 32 /* Class */) {
if (!isClass && !isInterface) {
ts.Debug.fail("type must be class or interface");
}
if (isClass) {
resolveBaseTypesOfClass(type);
}
else if (type.symbol.flags & 64 /* Interface */) {
if (isInterface) {
resolveBaseTypesOfInterface(type);
}
else {
ts.Debug.fail("type must be class or interface");
}
}
return type.resolvedBaseTypes;
}
function resolveBaseTypesOfClass(type) {
type.resolvedBaseTypes = emptyArray;
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
var baseContructorType = getBaseConstructorTypeOfClass(type);
if (!(baseContructorType.flags & 80896 /* ObjectType */)) {
return;
@ -15861,10 +15875,15 @@ var ts;
error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */));
return;
}
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
function resolveBaseTypesOfInterface(type) {
type.resolvedBaseTypes = [];
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) {
@ -15874,8 +15893,13 @@ var ts;
if (baseType !== unknownType) {
if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) {
if (type !== baseType && !hasBaseType(baseType, type)) {
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
else {
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */));
}
@ -16199,7 +16223,7 @@ var ts;
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
function getDefaultConstructSignatures(classType) {
if (!getBaseTypes(classType).length) {
if (!hasClassBaseType(classType)) {
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
}
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
@ -16638,7 +16662,9 @@ var ts;
function getSignatureFromDeclaration(declaration) {
var links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
var classType = declaration.kind === 144 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined;
var classType = declaration.kind === 144 /* Constructor */ ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
: undefined;
var typeParameters = classType ? classType.localTypeParameters :
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
var parameters = [];
@ -17717,7 +17743,7 @@ var ts;
if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) {
// Report structural errors only if we haven't reported any errors yet
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) {
if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) {
errorInfo = saveErrorInfo;
return result;
}
@ -17737,7 +17763,7 @@ var ts;
return result;
}
}
return objectTypeRelatedTo(source, target, /*reportErrors*/ false);
return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false);
}
if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) {
return typeParameterIdenticalTo(source, target);
@ -17763,20 +17789,19 @@ var ts;
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & 49152 /* UnionOrIntersection */) {
else if (type.flags & 49152 /* UnionOrIntersection */) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
}
return false;
}
return true;
}
function hasExcessProperties(source, target, reportErrors) {
if (someConstituentTypeHasKind(target, 80896 /* ObjectType */)) {
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
@ -17791,6 +17816,8 @@ var ts;
}
}
}
return false;
}
function eachTypeRelatedToSomeType(source, target) {
var result = -1 /* True */;
var sourceTypes = source.types;
@ -17884,11 +17911,11 @@ var ts;
// Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
// equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion
// and issue an error. Otherwise, actually compare the structure of the two types.
function objectTypeRelatedTo(source, target, reportErrors) {
function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) {
if (overflow) {
return 0 /* False */;
}
var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id;
var related = relation[id];
if (related !== undefined) {
// If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate
@ -17915,13 +17942,13 @@ var ts;
maybeStack = [];
expandingFlags = 0;
}
sourceStack[depth] = source;
sourceStack[depth] = apparentSource;
targetStack[depth] = target;
maybeStack[depth] = {};
maybeStack[depth][id] = 1 /* Succeeded */;
depth++;
var saveExpandingFlags = expandingFlags;
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth))
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth))
expandingFlags |= 1;
if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth))
expandingFlags |= 2;
@ -17930,15 +17957,15 @@ var ts;
result = 1 /* Maybe */;
}
else {
result = propertiesRelatedTo(source, target, reportErrors);
result = propertiesRelatedTo(apparentSource, target, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 0 /* Call */, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 1 /* Construct */, reportErrors);
if (result) {
result &= stringIndexTypesRelatedTo(source, target, reportErrors);
result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
if (result) {
result &= numberIndexTypesRelatedTo(source, target, reportErrors);
result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
}
}
}
@ -18235,12 +18262,17 @@ var ts;
}
return result;
}
function stringIndexTypesRelatedTo(source, target, reportErrors) {
function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(0 /* String */, source, target);
}
var targetType = getIndexTypeOfType(target, 0 /* String */);
if (targetType && !(targetType.flags & 1 /* Any */)) {
if (targetType) {
if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) {
// non-primitive assignment to any is always allowed, eg
// `var x: { [index: string]: any } = { property: 12 };`
return -1 /* True */;
}
var sourceType = getIndexTypeOfType(source, 0 /* String */);
if (!sourceType) {
if (reportErrors) {
@ -18259,12 +18291,17 @@ var ts;
}
return -1 /* True */;
}
function numberIndexTypesRelatedTo(source, target, reportErrors) {
function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(1 /* Number */, source, target);
}
var targetType = getIndexTypeOfType(target, 1 /* Number */);
if (targetType && !(targetType.flags & 1 /* Any */)) {
if (targetType) {
if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) {
// non-primitive assignment to any is always allowed, eg
// `var x: { [index: number]: any } = { property: 12 };`
return -1 /* True */;
}
var sourceStringType = getIndexTypeOfType(source, 0 /* String */);
var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */);
if (!(sourceStringType || sourceNumberType)) {
@ -18384,11 +18421,10 @@ var ts;
// M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N
source = getErasedSignature(source);
target = getErasedSignature(target);
var sourceLen = source.parameters.length;
var targetLen = target.parameters.length;
for (var i = 0; i < targetLen; i++) {
var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var related = compareTypes(s, t);
if (!related) {
return 0 /* False */;
@ -18400,6 +18436,9 @@ var ts;
}
return result;
}
function isRestParameterIndex(signature, parameterIndex) {
return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1;
}
function isSupertypeOfEach(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
@ -19469,8 +19508,9 @@ var ts;
return getTypeAtPosition(contextualSignature, indexOfParameter);
}
// If last parameter is contextually rest parameter get its type
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
if (funcHasRestParameters &&
indexOfParameter === (func.parameters.length - 1) &&
isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
@ -20132,9 +20172,6 @@ var ts;
case 234 /* JsxSelfClosingElement */:
checkJsxSelfClosingElement(child);
break;
default:
// No checks for JSX Text
ts.Debug.assert(child.kind === 236 /* JsxText */);
}
}
return jsxElementType || anyType;
@ -20894,7 +20931,7 @@ var ts;
// If spread arguments are present, check that they correspond to a rest parameter. If so, no
// further checking is necessary.
if (spreadArgIndex >= 0) {
return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1;
return isRestParameterIndex(signature, spreadArgIndex);
}
// Too many arguments implies incorrect arity.
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
@ -21124,36 +21161,34 @@ var ts;
*/
function getEffectiveDecoratorFirstArgumentType(node) {
// The first argument to a decorator is its `target`.
switch (node.kind) {
case 214 /* ClassDeclaration */:
case 186 /* ClassExpression */:
if (node.kind === 214 /* ClassDeclaration */) {
// For a class decorator, the `target` is the type of the class (e.g. the
// "static" or "constructor" side of the class)
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
case 138 /* Parameter */:
}
if (node.kind === 138 /* Parameter */) {
// For a parameter decorator, the `target` is the parent type of the
// parameter's containing method.
node = node.parent;
if (node.kind === 144 /* Constructor */) {
var classSymbol_1 = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol_1);
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
}
// fall-through
case 141 /* PropertyDeclaration */:
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
}
if (node.kind === 141 /* PropertyDeclaration */ ||
node.kind === 143 /* MethodDeclaration */ ||
node.kind === 145 /* GetAccessor */ ||
node.kind === 146 /* SetAccessor */) {
// For a property or method decorator, the `target` is the
// "static"-side type of the parent of the member if the member is
// declared "static"; otherwise, it is the "instance"-side type of the
// parent of the member.
return getParentTypeOfClassElement(node);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
/**
* Returns the effective type for the second argument to a decorator.
* If 'node' is a parameter, its effective argument type is one of the following:
@ -21171,23 +21206,21 @@ var ts;
*/
function getEffectiveDecoratorSecondArgumentType(node) {
// The second argument to a decorator is its `propertyKey`
switch (node.kind) {
case 214 /* ClassDeclaration */:
if (node.kind === 214 /* ClassDeclaration */) {
ts.Debug.fail("Class decorators should not have a second synthetic argument.");
return unknownType;
case 138 /* Parameter */:
}
if (node.kind === 138 /* Parameter */) {
node = node.parent;
if (node.kind === 144 /* Constructor */) {
// For a constructor parameter decorator, the `propertyKey` will be `undefined`.
return anyType;
}
// For a non-constructor parameter decorator, the `propertyKey` will be either
// a string or a symbol, based on the name of the parameter's containing method.
// fall-through
case 141 /* PropertyDeclaration */:
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
}
if (node.kind === 141 /* PropertyDeclaration */ ||
node.kind === 143 /* MethodDeclaration */ ||
node.kind === 145 /* GetAccessor */ ||
node.kind === 146 /* SetAccessor */) {
// The `propertyKey` for a property or method decorator will be a
// string literal type if the member name is an identifier, number, or string;
// otherwise, if the member name is a computed property name it will
@ -21210,11 +21243,10 @@ var ts;
ts.Debug.fail("Unsupported property name.");
return unknownType;
}
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
/**
* Returns the effective argument type for the third argument to a decorator.
* If 'node' is a parameter, the effective argument type is the number type.
@ -21225,28 +21257,29 @@ var ts;
function getEffectiveDecoratorThirdArgumentType(node) {
// The third argument to a decorator is either its `descriptor` for a method decorator
// or its `parameterIndex` for a paramter decorator
switch (node.kind) {
case 214 /* ClassDeclaration */:
if (node.kind === 214 /* ClassDeclaration */) {
ts.Debug.fail("Class decorators should not have a third synthetic argument.");
return unknownType;
case 138 /* Parameter */:
}
if (node.kind === 138 /* Parameter */) {
// The `parameterIndex` for a parameter decorator is always a number
return numberType;
case 141 /* PropertyDeclaration */:
}
if (node.kind === 141 /* PropertyDeclaration */) {
ts.Debug.fail("Property decorators should not have a third synthetic argument.");
return unknownType;
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
}
if (node.kind === 143 /* MethodDeclaration */ ||
node.kind === 145 /* GetAccessor */ ||
node.kind === 146 /* SetAccessor */) {
// The `descriptor` for a method decorator will be a `TypedPropertyDescriptor<T>`
// for the type of the member.
var propertyType = getTypeOfNode(node);
return createTypedPropertyDescriptorType(propertyType);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
/**
* Returns the effective argument type for the provided argument to a decorator.
*/
@ -21771,7 +21804,7 @@ var ts;
var contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
var parameter = ts.lastOrUndefined(signature.parameters);
var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
@ -23268,7 +23301,12 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedNodeFlags(n);
if (n.parent.kind !== 215 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
// children of classes (even ambient classes) should not be marked as ambient or export
// because those flags have no useful semantics there.
if (n.parent.kind !== 215 /* InterfaceDeclaration */ &&
n.parent.kind !== 214 /* ClassDeclaration */ &&
n.parent.kind !== 186 /* ClassExpression */ &&
ts.isInAmbientContext(n)) {
if (!(flags & 2 /* Ambient */)) {
// It is nested in an ambient context, which means it is automatically exported
flags |= 1 /* Export */;
@ -24862,10 +24900,6 @@ var ts;
grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkClassLikeDeclaration(node);
// Interfaces cannot be merged with non-ambient classes.
if (getSymbolOfNode(node).flags & 64 /* Interface */ && !ts.isInAmbientContext(node)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
}
ts.forEach(node.members, checkSourceElement);
}
function checkClassLikeDeclaration(node) {
@ -25122,16 +25156,6 @@ var ts;
checkIndexConstraints(type);
}
}
// Interfaces cannot merge with non-ambient classes.
if (symbol && symbol.declarations) {
for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
var declaration = _c[_b];
if (declaration.kind === 214 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
break;
}
}
}
}
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
@ -30708,7 +30732,8 @@ var ts;
write(".");
}
}
else if (modulekind !== 5 /* ES6 */) {
else {
if (modulekind !== 5 /* ES6 */) {
var declaration = resolver.getReferencedImportDeclaration(node);
if (declaration) {
if (declaration.kind === 223 /* ImportClause */) {
@ -30732,12 +30757,15 @@ var ts;
return;
}
}
declaration = resolver.getReferencedNestedRedeclaration(node);
}
if (languageVersion !== 2 /* ES6 */) {
var declaration = resolver.getReferencedNestedRedeclaration(node);
if (declaration) {
write(getGeneratedNameForNode(declaration.name));
return;
}
}
}
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
@ -31594,7 +31622,7 @@ var ts;
* we we emit variable statement 'var' should be dropped.
*/
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) {
if (!node || !isCurrentFileSystemExternalModule()) {
return false;
}
var current = node;
@ -36813,7 +36841,7 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2 /* ES6 */) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
@ -36828,7 +36856,7 @@ var ts;
}
// Cannot specify module gen target of es6 when below es6
if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
}
// there has to be common source directory if user specified --outdir || --sourceRoot
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
@ -36954,9 +36982,9 @@ var ts;
"es6": 5 /* ES6 */,
"es2015": 5 /* ES2015 */
},
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015
},
{
name: "newLine",
@ -37087,9 +37115,9 @@ var ts;
"es6": 2 /* ES6 */,
"es2015": 2 /* ES2015 */
},
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental,
paramType: ts.Diagnostics.VERSION,
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015
},
{
name: "version",
@ -37271,60 +37299,17 @@ var ts;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param host Instance of ParseConfigHost used to enumerate files in folder.
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseJsonConfigFileContent(json, host, basePath) {
var errors = [];
var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors;
return {
options: getCompilerOptions(),
options: options,
fileNames: getFileNames(),
errors: errors
};
function getCompilerOptions() {
var options = {};
var optionNameMap = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name] = option;
});
var jsonOptions = json["compilerOptions"];
if (jsonOptions) {
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
}
return options;
}
function getFileNames() {
var fileNames = [];
if (ts.hasProperty(json, "files")) {
@ -37360,6 +37345,49 @@ var ts;
}
}
ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
function convertCompilerOptionsFromJson(jsonOptions, basePath) {
var options = {};
var errors = [];
if (!jsonOptions) {
return { options: options, errors: errors };
}
var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; });
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
return { options: options, errors: errors };
}
ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
})(ts || (ts = {}));
/* @internal */
var ts;
@ -41923,8 +41951,8 @@ var ts;
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
if (isTokenInRange) {
var rangeHasError = rangeContainsError(currentTokenInfo.token);
// save prevStartLine since processRange will overwrite this value with current ones
var prevStartLine = previousRangeStartLine;
// save previousRange since processRange will overwrite this value with current one
var savePreviousRange = previousRange;
lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
if (rangeHasError) {
// do not indent comments\token if token range overlaps with some error
@ -41935,7 +41963,9 @@ var ts;
indentToken = lineAdded;
}
else {
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine;
// indent token only if end line of previous range does not match start line of the token
var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
}
}
}
@ -42792,9 +42822,7 @@ var ts;
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new (ts.getNodeConstructor(kind))();
node.pos = pos;
node.end = end;
var node = new (ts.getNodeConstructor(kind))(pos, end);
node.flags = flags;
node.parent = parent;
return node;
@ -49105,14 +49133,14 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
}
var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
proto.kind = kind;
proto.pos = -1;
proto.end = -1;
proto.flags = 0;
proto.parent = undefined;
Node.prototype = proto;
return Node;
},

View file

@ -328,6 +328,7 @@ declare namespace ts {
FirstNode = 135,
}
const enum NodeFlags {
None = 0,
Export = 1,
Ambient = 2,
Public = 16,
@ -954,7 +955,7 @@ declare namespace ts {
getSourceFile(fileName: string): SourceFile;
getCurrentDirectory(): string;
}
interface ParseConfigHost extends ModuleResolutionHost {
interface ParseConfigHost {
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
}
interface WriteFileCallback {
@ -1521,11 +1522,10 @@ declare namespace ts {
*/
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function arrayStructurallyIsEqualTo<T>(array1: Array<T>, array2: Array<T>): boolean;
}
declare namespace ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
@ -1564,10 +1564,15 @@ declare namespace ts {
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param host Instance of ParseConfigHost used to enumerate files in folder.
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine;
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): {
options: CompilerOptions;
errors: Diagnostic[];
};
}
declare namespace ts {
/** The version of the language service API */

View file

@ -349,6 +349,7 @@ var ts;
})(ts.SyntaxKind || (ts.SyntaxKind = {}));
var SyntaxKind = ts.SyntaxKind;
(function (NodeFlags) {
NodeFlags[NodeFlags["None"] = 0] = "None";
NodeFlags[NodeFlags["Export"] = 1] = "Export";
NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient";
NodeFlags[NodeFlags["Public"] = 16] = "Public";
@ -1567,15 +1568,13 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
}
Node.prototype = {
kind: kind,
pos: -1,
end: -1,
flags: 0,
parent: undefined
};
Node.prototype = { kind: kind };
return Node;
},
getSymbolConstructor: function () { return Symbol; },
@ -1613,9 +1612,10 @@ var ts;
})(Debug = ts.Debug || (ts.Debug = {}));
function copyListRemovingItem(item, list) {
var copiedList = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] !== item) {
copiedList.push(list[i]);
for (var _i = 0; _i < list.length; _i++) {
var e = list[_i];
if (e !== item) {
copiedList.push(e);
}
}
return copiedList;
@ -1959,7 +1959,7 @@ var ts;
watchDirectory: function (path, callback, recursive) {
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
return _fs.watch(path, { persisten: true, recursive: !!recursive }, function (eventName, relativeFileName) {
return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) {
// In watchDirectory we only care about adding and removing files (when event name is
// "rename"); changes made within files are handled by corresponding fileWatchers (when
// event name is "change")
@ -2178,7 +2178,7 @@ var ts;
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." },
Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." },
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." },
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." },
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
@ -2426,7 +2426,6 @@ var ts;
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." },
Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." },
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." },
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
@ -2452,6 +2451,7 @@ var ts;
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" },
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}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@ -2532,7 +2532,7 @@ var ts;
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." },
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}'." },
@ -2547,8 +2547,8 @@ var ts;
Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." },
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." },
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" },
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." },
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." },
Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." },
@ -2569,8 +2569,8 @@ var ts;
Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." },
Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." },
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." },
Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
@ -5173,15 +5173,15 @@ var ts;
return node.end - node.pos;
}
ts.getFullWidth = getFullWidth;
function arrayIsEqualTo(arr1, arr2, comparer) {
if (!arr1 || !arr2) {
return arr1 === arr2;
function arrayIsEqualTo(array1, array2, equaler) {
if (!array1 || !array2) {
return array1 === array2;
}
if (arr1.length !== arr2.length) {
if (array1.length !== array2.length) {
return false;
}
for (var i = 0; i < arr1.length; ++i) {
var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i];
for (var i = 0; i < array1.length; ++i) {
var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
if (!equals) {
return false;
}
@ -6539,7 +6539,7 @@ var ts;
}
ts.nodeIsSynthesized = nodeIsSynthesized;
function createSynthesizedNode(kind, startsOnNewLine) {
var node = ts.createNode(kind);
var node = ts.createNode(kind, /* pos */ -1, /* end */ -1);
node.startsOnNewLine = startsOnNewLine;
return node;
}
@ -7372,16 +7372,6 @@ var ts;
}
}
ts.getTypeParameterOwner = getTypeParameterOwner;
function arrayStructurallyIsEqualTo(array1, array2) {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return ts.arrayIsEqualTo(array1.sort(), array2.sort());
}
ts.arrayStructurallyIsEqualTo = arrayStructurallyIsEqualTo;
})(ts || (ts = {}));
/// <reference path="scanner.ts"/>
/// <reference path="utilities.ts"/>
@ -7393,8 +7383,8 @@ var ts;
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
}
ts.getNodeConstructor = getNodeConstructor;
function createNode(kind) {
return new (getNodeConstructor(kind))();
function createNode(kind, pos, end) {
return new (getNodeConstructor(kind))(pos, end);
}
ts.createNode = createNode;
function visitNode(cbNode, node) {
@ -8284,13 +8274,10 @@ var ts;
}
function createNode(kind, pos) {
nodeCount++;
var node = new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))();
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
node.pos = pos;
node.end = pos;
return node;
return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -10432,18 +10419,40 @@ var ts;
}
function parseJsxElementOrSelfClosingElement(inExpressionContext) {
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
var result;
if (opening.kind === 235 /* JsxOpeningElement */) {
var node = createNode(233 /* JsxElement */, opening.pos);
node.openingElement = opening;
node.children = parseJsxChildren(node.openingElement.tagName);
node.closingElement = parseJsxClosingElement(inExpressionContext);
return finishNode(node);
result = finishNode(node);
}
else {
ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */);
// Nothing else to do for self-closing elements
return opening;
result = opening;
}
// If the user writes the invalid code '<div></div><div></div>' in an expression context (i.e. not wrapped in
// an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag
// as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX
// element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter
// does less damage and we can report a better error.
// Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios
// of one sort or another.
if (inExpressionContext && token === 25 /* LessThanToken */) {
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); });
if (invalidElement) {
parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
var badNode = createNode(181 /* BinaryExpression */, result.pos);
badNode.end = invalidElement.end;
badNode.left = result;
badNode.right = invalidElement;
badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined);
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
return badNode;
}
}
return result;
}
function parseJsxText() {
var node = createNode(236 /* JsxText */, scanner.getStartPos());
@ -15811,22 +15820,27 @@ var ts;
}
return type.resolvedBaseConstructorType;
}
function hasClassBaseType(type) {
return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); });
}
function getBaseTypes(type) {
var isClass = type.symbol.flags & 32 /* Class */;
var isInterface = type.symbol.flags & 64 /* Interface */;
if (!type.resolvedBaseTypes) {
if (type.symbol.flags & 32 /* Class */) {
if (!isClass && !isInterface) {
ts.Debug.fail("type must be class or interface");
}
if (isClass) {
resolveBaseTypesOfClass(type);
}
else if (type.symbol.flags & 64 /* Interface */) {
if (isInterface) {
resolveBaseTypesOfInterface(type);
}
else {
ts.Debug.fail("type must be class or interface");
}
}
return type.resolvedBaseTypes;
}
function resolveBaseTypesOfClass(type) {
type.resolvedBaseTypes = emptyArray;
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
var baseContructorType = getBaseConstructorTypeOfClass(type);
if (!(baseContructorType.flags & 80896 /* ObjectType */)) {
return;
@ -15861,10 +15875,15 @@ var ts;
error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */));
return;
}
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
function resolveBaseTypesOfInterface(type) {
type.resolvedBaseTypes = [];
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) {
@ -15874,8 +15893,13 @@ var ts;
if (baseType !== unknownType) {
if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) {
if (type !== baseType && !hasBaseType(baseType, type)) {
if (type.resolvedBaseTypes === emptyArray) {
type.resolvedBaseTypes = [baseType];
}
else {
type.resolvedBaseTypes.push(baseType);
}
}
else {
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */));
}
@ -16199,7 +16223,7 @@ var ts;
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
function getDefaultConstructSignatures(classType) {
if (!getBaseTypes(classType).length) {
if (!hasClassBaseType(classType)) {
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
}
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
@ -16638,7 +16662,9 @@ var ts;
function getSignatureFromDeclaration(declaration) {
var links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
var classType = declaration.kind === 144 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined;
var classType = declaration.kind === 144 /* Constructor */ ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
: undefined;
var typeParameters = classType ? classType.localTypeParameters :
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
var parameters = [];
@ -17717,7 +17743,7 @@ var ts;
if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) {
// Report structural errors only if we haven't reported any errors yet
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) {
if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) {
errorInfo = saveErrorInfo;
return result;
}
@ -17737,7 +17763,7 @@ var ts;
return result;
}
}
return objectTypeRelatedTo(source, target, /*reportErrors*/ false);
return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false);
}
if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) {
return typeParameterIdenticalTo(source, target);
@ -17763,20 +17789,19 @@ var ts;
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & 49152 /* UnionOrIntersection */) {
else if (type.flags & 49152 /* UnionOrIntersection */) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name)) {
return true;
}
}
}
return false;
}
return true;
}
function hasExcessProperties(source, target, reportErrors) {
if (someConstituentTypeHasKind(target, 80896 /* ObjectType */)) {
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
if (!isKnownProperty(target, prop.name)) {
@ -17791,6 +17816,8 @@ var ts;
}
}
}
return false;
}
function eachTypeRelatedToSomeType(source, target) {
var result = -1 /* True */;
var sourceTypes = source.types;
@ -17884,11 +17911,11 @@ var ts;
// Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
// equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion
// and issue an error. Otherwise, actually compare the structure of the two types.
function objectTypeRelatedTo(source, target, reportErrors) {
function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) {
if (overflow) {
return 0 /* False */;
}
var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id;
var related = relation[id];
if (related !== undefined) {
// If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate
@ -17915,13 +17942,13 @@ var ts;
maybeStack = [];
expandingFlags = 0;
}
sourceStack[depth] = source;
sourceStack[depth] = apparentSource;
targetStack[depth] = target;
maybeStack[depth] = {};
maybeStack[depth][id] = 1 /* Succeeded */;
depth++;
var saveExpandingFlags = expandingFlags;
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth))
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth))
expandingFlags |= 1;
if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth))
expandingFlags |= 2;
@ -17930,15 +17957,15 @@ var ts;
result = 1 /* Maybe */;
}
else {
result = propertiesRelatedTo(source, target, reportErrors);
result = propertiesRelatedTo(apparentSource, target, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 0 /* Call */, reportErrors);
if (result) {
result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors);
result &= signaturesRelatedTo(apparentSource, target, 1 /* Construct */, reportErrors);
if (result) {
result &= stringIndexTypesRelatedTo(source, target, reportErrors);
result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
if (result) {
result &= numberIndexTypesRelatedTo(source, target, reportErrors);
result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors);
}
}
}
@ -18235,12 +18262,17 @@ var ts;
}
return result;
}
function stringIndexTypesRelatedTo(source, target, reportErrors) {
function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(0 /* String */, source, target);
}
var targetType = getIndexTypeOfType(target, 0 /* String */);
if (targetType && !(targetType.flags & 1 /* Any */)) {
if (targetType) {
if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) {
// non-primitive assignment to any is always allowed, eg
// `var x: { [index: string]: any } = { property: 12 };`
return -1 /* True */;
}
var sourceType = getIndexTypeOfType(source, 0 /* String */);
if (!sourceType) {
if (reportErrors) {
@ -18259,12 +18291,17 @@ var ts;
}
return -1 /* True */;
}
function numberIndexTypesRelatedTo(source, target, reportErrors) {
function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) {
if (relation === identityRelation) {
return indexTypesIdenticalTo(1 /* Number */, source, target);
}
var targetType = getIndexTypeOfType(target, 1 /* Number */);
if (targetType && !(targetType.flags & 1 /* Any */)) {
if (targetType) {
if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) {
// non-primitive assignment to any is always allowed, eg
// `var x: { [index: number]: any } = { property: 12 };`
return -1 /* True */;
}
var sourceStringType = getIndexTypeOfType(source, 0 /* String */);
var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */);
if (!(sourceStringType || sourceNumberType)) {
@ -18384,11 +18421,10 @@ var ts;
// M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N
source = getErasedSignature(source);
target = getErasedSignature(target);
var sourceLen = source.parameters.length;
var targetLen = target.parameters.length;
for (var i = 0; i < targetLen; i++) {
var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var related = compareTypes(s, t);
if (!related) {
return 0 /* False */;
@ -18400,6 +18436,9 @@ var ts;
}
return result;
}
function isRestParameterIndex(signature, parameterIndex) {
return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1;
}
function isSupertypeOfEach(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
@ -19469,8 +19508,9 @@ var ts;
return getTypeAtPosition(contextualSignature, indexOfParameter);
}
// If last parameter is contextually rest parameter get its type
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
if (funcHasRestParameters &&
indexOfParameter === (func.parameters.length - 1) &&
isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
@ -20132,9 +20172,6 @@ var ts;
case 234 /* JsxSelfClosingElement */:
checkJsxSelfClosingElement(child);
break;
default:
// No checks for JSX Text
ts.Debug.assert(child.kind === 236 /* JsxText */);
}
}
return jsxElementType || anyType;
@ -20894,7 +20931,7 @@ var ts;
// If spread arguments are present, check that they correspond to a rest parameter. If so, no
// further checking is necessary.
if (spreadArgIndex >= 0) {
return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1;
return isRestParameterIndex(signature, spreadArgIndex);
}
// Too many arguments implies incorrect arity.
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
@ -21124,36 +21161,34 @@ var ts;
*/
function getEffectiveDecoratorFirstArgumentType(node) {
// The first argument to a decorator is its `target`.
switch (node.kind) {
case 214 /* ClassDeclaration */:
case 186 /* ClassExpression */:
if (node.kind === 214 /* ClassDeclaration */) {
// For a class decorator, the `target` is the type of the class (e.g. the
// "static" or "constructor" side of the class)
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
case 138 /* Parameter */:
}
if (node.kind === 138 /* Parameter */) {
// For a parameter decorator, the `target` is the parent type of the
// parameter's containing method.
node = node.parent;
if (node.kind === 144 /* Constructor */) {
var classSymbol_1 = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol_1);
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
}
// fall-through
case 141 /* PropertyDeclaration */:
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
}
if (node.kind === 141 /* PropertyDeclaration */ ||
node.kind === 143 /* MethodDeclaration */ ||
node.kind === 145 /* GetAccessor */ ||
node.kind === 146 /* SetAccessor */) {
// For a property or method decorator, the `target` is the
// "static"-side type of the parent of the member if the member is
// declared "static"; otherwise, it is the "instance"-side type of the
// parent of the member.
return getParentTypeOfClassElement(node);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
/**
* Returns the effective type for the second argument to a decorator.
* If 'node' is a parameter, its effective argument type is one of the following:
@ -21171,23 +21206,21 @@ var ts;
*/
function getEffectiveDecoratorSecondArgumentType(node) {
// The second argument to a decorator is its `propertyKey`
switch (node.kind) {
case 214 /* ClassDeclaration */:
if (node.kind === 214 /* ClassDeclaration */) {
ts.Debug.fail("Class decorators should not have a second synthetic argument.");
return unknownType;
case 138 /* Parameter */:
}
if (node.kind === 138 /* Parameter */) {
node = node.parent;
if (node.kind === 144 /* Constructor */) {
// For a constructor parameter decorator, the `propertyKey` will be `undefined`.
return anyType;
}
// For a non-constructor parameter decorator, the `propertyKey` will be either
// a string or a symbol, based on the name of the parameter's containing method.
// fall-through
case 141 /* PropertyDeclaration */:
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
}
if (node.kind === 141 /* PropertyDeclaration */ ||
node.kind === 143 /* MethodDeclaration */ ||
node.kind === 145 /* GetAccessor */ ||
node.kind === 146 /* SetAccessor */) {
// The `propertyKey` for a property or method decorator will be a
// string literal type if the member name is an identifier, number, or string;
// otherwise, if the member name is a computed property name it will
@ -21210,11 +21243,10 @@ var ts;
ts.Debug.fail("Unsupported property name.");
return unknownType;
}
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
/**
* Returns the effective argument type for the third argument to a decorator.
* If 'node' is a parameter, the effective argument type is the number type.
@ -21225,28 +21257,29 @@ var ts;
function getEffectiveDecoratorThirdArgumentType(node) {
// The third argument to a decorator is either its `descriptor` for a method decorator
// or its `parameterIndex` for a paramter decorator
switch (node.kind) {
case 214 /* ClassDeclaration */:
if (node.kind === 214 /* ClassDeclaration */) {
ts.Debug.fail("Class decorators should not have a third synthetic argument.");
return unknownType;
case 138 /* Parameter */:
}
if (node.kind === 138 /* Parameter */) {
// The `parameterIndex` for a parameter decorator is always a number
return numberType;
case 141 /* PropertyDeclaration */:
}
if (node.kind === 141 /* PropertyDeclaration */) {
ts.Debug.fail("Property decorators should not have a third synthetic argument.");
return unknownType;
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
}
if (node.kind === 143 /* MethodDeclaration */ ||
node.kind === 145 /* GetAccessor */ ||
node.kind === 146 /* SetAccessor */) {
// The `descriptor` for a method decorator will be a `TypedPropertyDescriptor<T>`
// for the type of the member.
var propertyType = getTypeOfNode(node);
return createTypedPropertyDescriptorType(propertyType);
default:
}
ts.Debug.fail("Unsupported decorator target.");
return unknownType;
}
}
/**
* Returns the effective argument type for the provided argument to a decorator.
*/
@ -21771,7 +21804,7 @@ var ts;
var contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
var parameter = ts.lastOrUndefined(signature.parameters);
var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
@ -23268,7 +23301,12 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedNodeFlags(n);
if (n.parent.kind !== 215 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
// children of classes (even ambient classes) should not be marked as ambient or export
// because those flags have no useful semantics there.
if (n.parent.kind !== 215 /* InterfaceDeclaration */ &&
n.parent.kind !== 214 /* ClassDeclaration */ &&
n.parent.kind !== 186 /* ClassExpression */ &&
ts.isInAmbientContext(n)) {
if (!(flags & 2 /* Ambient */)) {
// It is nested in an ambient context, which means it is automatically exported
flags |= 1 /* Export */;
@ -24862,10 +24900,6 @@ var ts;
grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkClassLikeDeclaration(node);
// Interfaces cannot be merged with non-ambient classes.
if (getSymbolOfNode(node).flags & 64 /* Interface */ && !ts.isInAmbientContext(node)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
}
ts.forEach(node.members, checkSourceElement);
}
function checkClassLikeDeclaration(node) {
@ -25122,16 +25156,6 @@ var ts;
checkIndexConstraints(type);
}
}
// Interfaces cannot merge with non-ambient classes.
if (symbol && symbol.declarations) {
for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
var declaration = _c[_b];
if (declaration.kind === 214 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) {
error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
break;
}
}
}
}
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
@ -30708,7 +30732,8 @@ var ts;
write(".");
}
}
else if (modulekind !== 5 /* ES6 */) {
else {
if (modulekind !== 5 /* ES6 */) {
var declaration = resolver.getReferencedImportDeclaration(node);
if (declaration) {
if (declaration.kind === 223 /* ImportClause */) {
@ -30732,12 +30757,15 @@ var ts;
return;
}
}
declaration = resolver.getReferencedNestedRedeclaration(node);
}
if (languageVersion !== 2 /* ES6 */) {
var declaration = resolver.getReferencedNestedRedeclaration(node);
if (declaration) {
write(getGeneratedNameForNode(declaration.name));
return;
}
}
}
if (ts.nodeIsSynthesized(node)) {
write(node.text);
}
@ -31594,7 +31622,7 @@ var ts;
* we we emit variable statement 'var' should be dropped.
*/
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) {
if (!node || !isCurrentFileSystemExternalModule()) {
return false;
}
var current = node;
@ -36813,7 +36841,7 @@ var ts;
var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; });
if (options.isolatedModules) {
if (!options.module && languageVersion < 2 /* ES6 */) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
}
var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; });
if (firstNonExternalModuleSourceFile) {
@ -36828,7 +36856,7 @@ var ts;
}
// Cannot specify module gen target of es6 when below es6
if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
}
// there has to be common source directory if user specified --outdir || --sourceRoot
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
@ -36954,9 +36982,9 @@ var ts;
"es6": 5 /* ES6 */,
"es2015": 5 /* ES2015 */
},
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015
},
{
name: "newLine",
@ -37087,9 +37115,9 @@ var ts;
"es6": 2 /* ES6 */,
"es2015": 2 /* ES2015 */
},
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental,
paramType: ts.Diagnostics.VERSION,
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015
},
{
name: "version",
@ -37271,60 +37299,17 @@ var ts;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param host Instance of ParseConfigHost used to enumerate files in folder.
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseJsonConfigFileContent(json, host, basePath) {
var errors = [];
var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors;
return {
options: getCompilerOptions(),
options: options,
fileNames: getFileNames(),
errors: errors
};
function getCompilerOptions() {
var options = {};
var optionNameMap = {};
ts.forEach(ts.optionDeclarations, function (option) {
optionNameMap[option.name] = option;
});
var jsonOptions = json["compilerOptions"];
if (jsonOptions) {
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
}
return options;
}
function getFileNames() {
var fileNames = [];
if (ts.hasProperty(json, "files")) {
@ -37360,6 +37345,49 @@ var ts;
}
}
ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
function convertCompilerOptionsFromJson(jsonOptions, basePath) {
var options = {};
var errors = [];
if (!jsonOptions) {
return { options: options, errors: errors };
}
var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; });
for (var id in jsonOptions) {
if (ts.hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
if (ts.hasProperty(optType, key)) {
value = optType[key];
}
else {
errors.push(ts.createCompilerDiagnostic(opt.error));
value = 0;
}
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
}
}
else {
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id));
}
}
return { options: options, errors: errors };
}
ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
})(ts || (ts = {}));
/* @internal */
var ts;
@ -41923,8 +41951,8 @@ var ts;
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
if (isTokenInRange) {
var rangeHasError = rangeContainsError(currentTokenInfo.token);
// save prevStartLine since processRange will overwrite this value with current ones
var prevStartLine = previousRangeStartLine;
// save previousRange since processRange will overwrite this value with current one
var savePreviousRange = previousRange;
lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
if (rangeHasError) {
// do not indent comments\token if token range overlaps with some error
@ -41935,7 +41963,9 @@ var ts;
indentToken = lineAdded;
}
else {
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine;
// indent token only if end line of previous range does not match start line of the token
var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
}
}
}
@ -42792,9 +42822,7 @@ var ts;
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new (ts.getNodeConstructor(kind))();
node.pos = pos;
node.end = end;
var node = new (ts.getNodeConstructor(kind))(pos, end);
node.flags = flags;
node.parent = parent;
return node;
@ -49105,14 +49133,14 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function (kind) {
function Node() {
function Node(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
}
var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
proto.kind = kind;
proto.pos = -1;
proto.end = -1;
proto.flags = 0;
proto.parent = undefined;
Node.prototype = proto;
return Node;
},