diff --git a/Jakefile.js b/Jakefile.js index 1f88ee39082..a0ec0d880fe 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -103,7 +103,15 @@ var serverSources = [ "server.ts" ].map(function (f) { return path.join(serverDirectory, f); -}); +}).concat(servicesSources); + +var languageServiceLibrarySources = [ + "editorServices.ts", + "protocol.d.ts", + "session.ts" +].map(function (f) { + return path.join(serverDirectory, f); +}).concat(servicesSources); var harnessSources = [ "harness.ts", @@ -361,7 +369,7 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca // Create the node definition file by replacing 'ts' module with '"typescript"' as a module. jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); - definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"'); + definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); fs.writeFileSync(nodeDefinitionsFile, definitionFileContents); }); @@ -369,6 +377,20 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca var serverFile = path.join(builtLocalDirectory, "tsserver.js"); compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true); +var lsslFile = path.join(builtLocalDirectory, "tslssl.js"); +compileFile( + lsslFile, + languageServiceLibrarySources, + [builtLocalDirectory, copyright].concat(languageServiceLibrarySources), + /*prefixes*/ [copyright], + /*useBuiltCompiler*/ true, + /*noOutFile*/ false, + /*generateDeclarations*/ true); + +// Local target to build the language service server library +desc("Builds language service server library"); +task("lssl", [lsslFile]); + // Local target to build the compiler and services desc("Builds the full compiler and services"); task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]); diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index fd048630ca1..af876765ab4 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index 1213967b972..50c7fcc9017 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } @@ -1880,6 +1880,7 @@ interface Map { } interface MapConstructor { + new (): Map; new (): Map; new (iterable: Iterable<[K, V]>): Map; prototype: Map; @@ -1896,6 +1897,7 @@ interface WeakMap { } interface WeakMapConstructor { + new (): WeakMap; new (): WeakMap; new (iterable: Iterable<[K, V]>): WeakMap; prototype: WeakMap; @@ -1917,6 +1919,7 @@ interface Set { } interface SetConstructor { + new (): Set; new (): Set; new (iterable: Iterable): Set; prototype: Set; @@ -1932,6 +1935,7 @@ interface WeakSet { } interface WeakSetConstructor { + new (): WeakSet; new (): WeakSet; new (iterable: Iterable): WeakSet; prototype: WeakSet; diff --git a/bin/lib.d.ts b/bin/lib.d.ts index 0e1176377b5..63a8adbeda4 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } @@ -3531,6 +3531,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -3593,7 +3598,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index 7638f0fba4c..b05be6cbee8 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -2361,6 +2361,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -2423,7 +2428,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index 2326b43207d..931d60ec47a 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } @@ -1880,6 +1880,7 @@ interface Map { } interface MapConstructor { + new (): Map; new (): Map; new (iterable: Iterable<[K, V]>): Map; prototype: Map; @@ -1896,6 +1897,7 @@ interface WeakMap { } interface WeakMapConstructor { + new (): WeakMap; new (): WeakMap; new (iterable: Iterable<[K, V]>): WeakMap; prototype: WeakMap; @@ -1917,6 +1919,7 @@ interface Set { } interface SetConstructor { + new (): Set; new (): Set; new (iterable: Iterable): Set; prototype: Set; @@ -1932,6 +1935,7 @@ interface WeakSet { } interface WeakSetConstructor { + new (): WeakSet; new (): WeakSet; new (iterable: Iterable): WeakSet; prototype: WeakSet; @@ -4909,6 +4913,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -4971,7 +4980,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { @@ -18015,7 +18024,17 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) => declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +interface DOMTokenList { + [Symbol.iterator](): IterableIterator; +} +interface NodeList { + [Symbol.iterator](): IterableIterator +} + +interface NodeListOf { + [Symbol.iterator](): IterableIterator +} ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts index 79eac80a8fd..d0caeccff92 100644 --- a/bin/lib.webworker.d.ts +++ b/bin/lib.webworker.d.ts @@ -2361,6 +2361,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -2423,7 +2428,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/bin/tsc.js b/bin/tsc.js index c55b3be37ba..9e1d681e218 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -31,6 +31,36 @@ var ts; /// var ts; (function (ts) { + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -498,7 +528,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); } @@ -1116,14 +1146,32 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1317,6 +1365,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, 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}'." }, @@ -1494,9 +1547,7 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } }; })(ts || (ts = {})); /// @@ -1526,7 +1577,7 @@ var ts; "false": 80, "finally": 81, "for": 82, - "from": 125, + "from": 126, "function": 83, "get": 116, "if": 84, @@ -1535,36 +1586,37 @@ var ts; "in": 86, "instanceof": 87, "interface": 103, + "is": 117, "let": 104, - "module": 117, - "namespace": 118, + "module": 118, + "namespace": 119, "new": 88, "null": 89, - "number": 120, + "number": 121, "package": 105, "private": 106, "protected": 107, "public": 108, - "require": 119, + "require": 120, "return": 90, - "set": 121, + "set": 122, "static": 109, - "string": 122, + "string": 123, "super": 91, "switch": 92, - "symbol": 123, + "symbol": 124, "this": 93, "throw": 94, "true": 95, "try": 96, - "type": 124, + "type": 125, "typeof": 97, "var": 98, "void": 99, "while": 100, "with": 101, "yield": 110, - "of": 126, + "of": 127, "{": 14, "}": 15, "(": 16, @@ -1767,6 +1819,25 @@ var ts; return ch >= 48 && ch <= 55; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + default: + return ch > 127; + } + } + ts.couldStartTrivia = couldStartTrivia; function skipTrivia(text, pos, stopAfterLineBreak) { while (true) { var ch = text.charCodeAt(pos); @@ -2229,7 +2300,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125) { + else if (text.charCodeAt(pos) === 125) { pos++; } else { @@ -2750,16 +2821,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 203 || node.kind === 204) { + if (node.kind === 205 || node.kind === 206) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 210 || node.kind === 209) && !(node.flags & 1)) { + else if ((node.kind === 212 || node.kind === 211) && !(node.flags & 1)) { return 0; } - else if (node.kind === 207) { + else if (node.kind === 209) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2775,7 +2846,7 @@ var ts; }); return state; } - else if (node.kind === 206) { + else if (node.kind === 208) { return getModuleInstanceState(node.body); } else { @@ -2794,11 +2865,14 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -2824,10 +2898,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 && node.name.kind === 8) { + if (node.kind === 208 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128) { + if (node.name.kind === 129) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -2835,22 +2909,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136: + case 137: return "__constructor"; - case 143: - case 139: - return "__call"; - case 144: + case 145: case 140: - return "__new"; + return "__call"; + case 146: case 141: + return "__new"; + case 142: return "__index"; - case 216: + case 218: return "__export"; - case 215: + case 217: return node.isExportEquals ? "export=" : "default"; - case 201: - case 202: + case 203: + case 204: return node.flags & 256 ? "default" : undefined; } } @@ -2865,6 +2939,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0, name)); + if (name && (includes & 788448)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -2889,7 +2966,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 218 || (node.kind === 209 && hasExportModifier)) { + if (node.kind === 220 || (node.kind === 211 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -2935,36 +3012,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175: - case 202: - case 203: + case 177: + case 204: case 205: - case 146: - case 155: + case 207: + case 148: + case 157: return 1; - case 139: case 140: case 141: - case 135: - case 134: - case 201: + case 142: case 136: + case 135: + case 203: case 137: case 138: - case 143: - case 144: - case 163: - case 164: - case 206: - case 228: - return 5; - case 224: - case 187: - case 188: - case 189: + case 139: + case 145: + case 146: + case 165: + case 166: case 208: + case 230: + case 206: + return 5; + case 226: + case 189: + case 190: + case 191: + case 210: return 2; - case 180: + case 182: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -2980,32 +3058,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 206: + case 208: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228: + case 230: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175: - case 202: + case 177: + case 204: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205: + case 207: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146: - case 155: - case 203: + case 148: + case 157: + case 205: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: - case 135: - case 134: + case 142: case 136: + case 135: case 137: case 138: - case 201: - case 163: - case 164: + case 139: + case 203: + case 165: + case 166: + case 206: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3029,11 +3108,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 ? node : node.body; - if (body.kind === 228 || body.kind === 207) { + var body = node.kind === 230 ? node : node.body; + if (body.kind === 230 || body.kind === 209) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 || stat.kind === 215) { + if (stat.kind === 218 || stat.kind === 217) { return true; } } @@ -3078,16 +3157,41 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65) { + continue; + } + var identifier = prop.name; + var currentKind = prop.kind === 227 || prop.kind === 228 || prop.kind === 136 + ? 1 + : 2; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 && existingKind === 1) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206: + case 208: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228: + case 230: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3103,79 +3207,223 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2, 107455); } + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 && + node.originalKeywordKind <= 110 && + !ts.isIdentifierName(node)) { + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + if (inStrictMode && node.expression.kind === 65) { + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + if (inStrictMode) { + if (node.operator === 38 || node.operator === 39) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } bindWorker(node); bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230: + case 209: + updateStrictModeStatementList(node.statements); + return; + case 182: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204: + case 177: + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 130: - return bindParameter(node); - case 199: - case 153: - return bindVariableDeclarationOrBindingElement(node); - case 133: - case 132: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 225: + case 65: + return checkStrictModeIdentifier(node); + case 172: + return checkStrictModeBinaryExpression(node); case 226: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); + return checkStrictModeCatchClause(node); + case 167: + return checkStrictModeDeleteExpression(node); + case 7: + return checkStrictModeNumericLiteral(node); + case 171: + return checkStrictModePostfixUnaryExpression(node); + case 170: + return checkStrictModePrefixUnaryExpression(node); + case 195: + return checkStrictModeWithStatement(node); + case 130: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 131: + return bindParameter(node); + case 201: + case 155: + return bindVariableDeclarationOrBindingElement(node); + case 134: + case 133: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 227: + case 228: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 229: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 139: case 140: case 141: + case 142: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 135: - case 134: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 201: - return declareSymbolAndAddToSymbolTable(node, 16, 106927); case 136: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 137: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 138: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 143: - case 144: - return bindFunctionOrConstructorType(node); - case 146: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 155: - return bindAnonymousDeclaration(node, 4096, "__object"); - case 163: - case 164: - return bindAnonymousDeclaration(node, 16, "__function"); - case 175: - case 202: - return bindClassLikeDeclaration(node); + case 135: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); case 203: - return bindBlockScopedDeclaration(node, 64, 792992); + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 137: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 138: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 139: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 145: + case 146: + return bindFunctionOrConstructorType(node); + case 148: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 157: + return bindObjectLiteralExpression(node); + case 165: + case 166: + checkStrictModeFunctionName(node); + return bindAnonymousDeclaration(node, 16, "__function"); + case 177: case 204: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindClassLikeDeclaration(node); case 205: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 792992); case 206: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 207: + return bindEnumDeclaration(node); + case 208: return bindModuleDeclaration(node); - case 209: - case 212: - case 214: - case 218: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 211: - return bindImportClause(node); + case 214: case 216: + case 220: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 213: + return bindImportClause(node); + case 218: return bindExportDeclaration(node); - case 215: + case 217: return bindExportAssignment(node); - case 228: + case 230: return bindSourceFileIfExternalModule(); } } @@ -3186,7 +3434,10 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); + } + else if (node.expression.kind === 65) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3194,7 +3445,10 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + } + else if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } } @@ -3204,7 +3458,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202) { + if (node.kind === 204) { bindBlockScopedDeclaration(node, 32, 899583); } else { @@ -3227,6 +3481,9 @@ var ts; : bindBlockScopedDeclaration(node, 256, 899327); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -3240,6 +3497,9 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); } @@ -3247,8 +3507,8 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 136 && - (node.parent.parent.kind === 202 || node.parent.parent.kind === 175)) { + node.parent.kind === 137 && + ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -3276,7 +3536,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -3323,7 +3583,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228) { + while (node && node.kind !== 230) { node = node.parent; } return node; @@ -3412,15 +3672,15 @@ var ts; return current; } switch (current.kind) { - case 228: + case 230: + case 210: + case 226: case 208: - case 224: - case 206: - case 187: - case 188: case 189: + case 190: + case 191: return current; - case 180: + case 182: if (!isFunctionLike(current.parent)) { return current; } @@ -3431,9 +3691,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 && + declaration.kind === 201 && declaration.parent && - declaration.parent.kind === 224; + declaration.parent.kind === 226; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3469,22 +3729,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228: + case 230: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 199: - case 153: - case 202: - case 175: - case 203: - case 206: - case 205: - case 227: case 201: - case 163: + case 155: + case 204: + case 177: + case 205: + case 208: + case 207: + case 229: + case 203: + case 165: errorNode = node.name; break; } @@ -3506,11 +3766,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 && isConst(node); + return node.kind === 207 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 || isBindingPattern(node))) { + while (node && (node.kind === 155 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3518,14 +3778,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199) { + if (node.kind === 201) { node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 202) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181) { + if (node && node.kind === 183) { flags |= node.flags; } return flags; @@ -3540,11 +3800,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 && node.expression.kind === 8; + return node.kind === 185 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 130 || node.kind === 129) { + if (node.kind === 131 || node.kind === 130) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3563,68 +3823,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 <= node.kind && node.kind <= 150) { + if (144 <= node.kind && node.kind <= 152) { return true; } switch (node.kind) { case 112: - case 120: - case 122: - case 113: + case 121: case 123: + case 113: + case 124: return true; case 99: - return node.parent.kind !== 167; + return node.parent.kind !== 169; case 8: - return node.parent.kind === 130; - case 177: - return true; + return node.parent.kind === 131; + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 65: - if (node.parent.kind === 127 && node.parent.right === node) { + if (node.parent.kind === 128 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 && node.parent.name === node) { + else if (node.parent.kind === 158 && node.parent.name === node) { node = node.parent; } - case 127: - case 156: - ts.Debug.assert(node.kind === 65 || node.kind === 127 || node.kind === 156, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 128: + case 158: + ts.Debug.assert(node.kind === 65 || node.kind === 128 || node.kind === 158, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145) { + if (parent_1.kind === 147) { return false; } - if (142 <= parent_1.kind && parent_1.kind <= 150) { + if (144 <= parent_1.kind && parent_1.kind <= 152) { return true; } switch (parent_1.kind) { - case 177: - return true; - case 129: - return node === parent_1.constraint; - case 133: - case 132: + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); case 130: - case 199: - return node === parent_1.type; + return node === parent_1.constraint; + case 134: + case 133: + case 131: case 201: - case 163: - case 164: + return node === parent_1.type; + case 203: + case 165: + case 166: + case 137: case 136: case 135: - case 134: - case 137: case 138: - return node === parent_1.type; case 139: + return node === parent_1.type; case 140: case 141: + case 142: return node === parent_1.type; - case 161: + case 163: return node === parent_1.type; - case 158: - case 159: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 160: + case 161: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 162: return false; } } @@ -3635,23 +3895,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192: + case 194: return visitor(node); - case 208: - case 180: - case 184: - case 185: + case 210: + case 182: case 186: case 187: case 188: case 189: - case 193: - case 194: - case 221: - case 222: + case 190: + case 191: case 195: - case 197: + case 196: + case 223: case 224: + case 197: + case 199: + case 226: return ts.forEachChild(node, traverse); } } @@ -3661,22 +3921,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173: + case 175: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 207: case 205: - case 203: + case 208: case 206: case 204: - case 202: + case 177: return; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128) { + if (name_4 && name_4.kind === 129) { traverse(name_4.expression); return; } @@ -3691,14 +3952,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153: + case 155: + case 229: + case 131: case 227: - case 130: - case 225: + case 134: case 133: - case 132: - case 226: - case 199: + case 228: + case 201: return true; } } @@ -3706,38 +3967,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - if (node) { - switch (node.kind) { - case 137: - case 138: - return true; - } - } - return false; + return node && (node.kind === 138 || node.kind === 139); } ts.isAccessor = isAccessor; function isClassLike(node) { - if (node) { - return node.kind === 202 || node.kind === 175; - } + return node && (node.kind === 204 || node.kind === 177); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136: - case 163: - case 201: - case 164: - case 135: - case 134: case 137: + case 165: + case 203: + case 166: + case 136: + case 135: case 138: case 139: case 140: case 141: - case 143: - case 144: + case 142: + case 145: + case 146: return true; } } @@ -3745,11 +3997,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 && isFunctionLike(node.parent); + return node && node.kind === 182 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 && node.parent.kind === 155; + return node && node.kind === 136 && node.parent.kind === 157; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3761,6 +4013,15 @@ var ts; } } ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { while (true) { node = node.parent; @@ -3768,36 +4029,36 @@ var ts; return undefined; } switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 164: + case 166: if (!includeArrowFunctions) { continue; } - case 201: - case 163: - case 206: - case 133: - case 132: - case 135: + case 203: + case 165: + case 208: case 134: + case 133: case 136: + case 135: case 137: case 138: - case 205: - case 228: + case 139: + case 207: + case 230: return node; } } @@ -3809,40 +4070,40 @@ var ts; if (!node) return node; switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 201: - case 163: - case 164: + case 203: + case 165: + case 166: if (!includeFunctions) { continue; } - case 133: - case 132: - case 135: case 134: + case 133: case 136: + case 135: case 137: case 138: + case 139: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160) { + if (node.kind === 162) { return node.tag; } return node.expression; @@ -3850,40 +4111,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202: + case 204: return true; - case 133: - return node.parent.kind === 202; - case 130: - return node.parent.body && node.parent.parent.kind === 202; - case 137: + case 134: + return node.parent.kind === 204; + case 131: + return node.parent.body && node.parent.parent.kind === 204; case 138: - case 135: - return node.body && node.parent.kind === 202; + case 139: + case 136: + return node.body && node.parent.kind === 204; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202: + case 204: if (node.decorators) { return true; } return false; - case 133: - case 130: + case 134: + case 131: if (node.decorators) { return true; } return false; - case 137: + case 138: if (node.body && node.decorators) { return true; } return false; - case 135: - case 138: + case 136: + case 139: if (node.body && node.decorators) { return true; } @@ -3894,10 +4155,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202: + case 204: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135: - case 138: + case 136: + case 139: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3915,8 +4176,6 @@ var ts; case 95: case 80: case 9: - case 154: - case 155: case 156: case 157: case 158: @@ -3925,71 +4184,75 @@ var ts; case 161: case 162: case 163: - case 175: case 164: - case 167: case 165: + case 177: case 166: - case 168: case 169: + case 167: + case 168: case 170: case 171: - case 174: case 172: - case 10: - case 176: case 173: + case 176: + case 174: + case 10: + case 178: + case 175: return true; - case 127: - while (node.parent.kind === 127) { + case 128: + while (node.parent.kind === 128) { node = node.parent; } - return node.parent.kind === 145; + return node.parent.kind === 147; case 65: - if (node.parent.kind === 145) { + if (node.parent.kind === 147) { return true; } case 7: case 8: var parent_2 = node.parent; switch (parent_2.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: + case 229: case 227: - case 225: - case 153: + case 155: return parent_2.initializer === node; - case 183: - case 184: case 185: case 186: - case 192: - case 193: - case 194: - case 221: - case 196: - case 194: - return parent_2.expression === node; case 187: + case 188: + case 194: + case 195: + case 196: + case 223: + case 198: + case 196: + return parent_2.expression === node; + case 189: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202) || forStatement.condition === node || forStatement.incrementor === node; - case 188: - case 189: + case 190: + case 191: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202) || forInStatement.expression === node; - case 161: + case 163: return node === parent_2.expression; - case 178: + case 180: return node === parent_2.expression; - case 128: + case 129: return node === parent_2.expression; - case 131: + case 132: return true; + case 179: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -4006,7 +4269,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind === 220; + return node.kind === 211 && node.moduleReference.kind === 222; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4015,20 +4278,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind !== 220; + return node.kind === 211 && node.moduleReference.kind !== 222; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } - if (node.kind === 209) { + if (node.kind === 211) { var reference = node.moduleReference; - if (reference.kind === 220) { + if (reference.kind === 222) { return reference.expression; } } - if (node.kind === 216) { + if (node.kind === 218) { return node.moduleSpecifier; } } @@ -4036,15 +4299,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130: + case 131: return node.questionToken !== undefined; + case 136: case 135: - case 134: return node.questionToken !== undefined; - case 226: - case 225: + case 228: + case 227: + case 134: case 133: - case 132: return node.questionToken !== undefined; } } @@ -4052,9 +4315,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 && + return node.kind === 243 && node.parameters.length > 0 && - node.parameters[0].type.kind === 243; + node.parameters[0].type.kind === 245; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4068,15 +4331,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249); + return getJSDocTag(node, 251); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248); + return getJSDocTag(node, 250); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250); + return getJSDocTag(node, 252); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -4085,7 +4348,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247) { + if (t.kind === 249) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -4104,12 +4367,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64) { - if (node.type && node.type.kind === 242) { + if (node.type && node.type.kind === 244) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242; + return paramTag.typeExpression.type.kind === 244; } } return node.dotDotDotToken !== undefined; @@ -4130,7 +4393,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 || node.kind === 151); + return !!node && (node.kind === 154 || node.kind === 153); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4145,33 +4408,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164: - case 153: - case 202: - case 136: - case 205: - case 227: - case 218: - case 201: - case 163: - case 137: - case 211: - case 209: - case 214: - case 203: - case 135: - case 134: - case 206: - case 212: - case 130: - case 225: - case 133: - case 132: - case 138: - case 226: + case 166: + case 155: case 204: - case 129: - case 199: + case 177: + case 137: + case 207: + case 229: + case 220: + case 203: + case 165: + case 138: + case 213: + case 211: + case 216: + case 205: + case 136: + case 135: + case 208: + case 214: + case 131: + case 227: + case 134: + case 133: + case 139: + case 228: + case 206: + case 130: + case 201: return true; } return false; @@ -4179,25 +4443,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191: - case 190: - case 198: - case 185: - case 183: - case 182: - case 188: - case 189: - case 187: - case 184: - case 195: - case 192: - case 194: - case 94: - case 197: - case 181: - case 186: case 193: - case 215: + case 192: + case 200: + case 187: + case 185: + case 184: + case 190: + case 191: + case 189: + case 186: + case 197: + case 194: + case 196: + case 94: + case 199: + case 183: + case 188: + case 195: + case 217: return true; default: return false; @@ -4206,13 +4470,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136: - case 133: - case 135: case 137: - case 138: case 134: - case 141: + case 136: + case 138: + case 139: + case 135: + case 142: return true; default: return false; @@ -4224,7 +4488,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 || parent.kind === 218) { + if (parent.kind === 216 || parent.kind === 220) { if (parent.propertyName) { return true; } @@ -4235,13 +4499,43 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134: + case 133: + case 136: + case 135: + case 138: + case 139: + case 229: + case 227: + case 158: + return parent.name === node; + case 128: + if (parent.right === node) { + while (parent.kind === 128) { + parent = parent.parent; + } + return parent.kind === 147; + } + return false; + case 155: + case 216: + return parent.propertyName === node; + case 220: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 209 || - node.kind === 211 && !!node.name || - node.kind === 212 || + return node.kind === 211 || + node.kind === 213 && !!node.name || node.kind === 214 || - node.kind === 218 || - node.kind === 215 && node.expression.kind === 65; + node.kind === 216 || + node.kind === 220 || + node.kind === 217 && node.expression.kind === 65; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4324,7 +4618,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 126; + return 66 <= token && token <= 127; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4333,19 +4627,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 && + declaration.name.kind === 129 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 && isESSymbolIdentifier(node.expression); + return node.kind === 158 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 128) { + if (name.kind === 129) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4380,18 +4674,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130; + return root.kind === 131; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153) { + while (node.kind === 155) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 || n.kind === 228; + return isFunctionLike(n) || n.kind === 208 || n.kind === 230; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4615,7 +4909,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 && nodeIsPresent(member.body)) { + if (member.kind === 137 && nodeIsPresent(member.body)) { return member; } }); @@ -4638,10 +4932,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137) { + if (accessor.kind === 138) { getAccessor = accessor; } - else if (accessor.kind === 138) { + else if (accessor.kind === 139) { setAccessor = accessor; } else { @@ -4650,7 +4944,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 || member.kind === 138) + if ((member.kind === 138 || member.kind === 139) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4661,10 +4955,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 && !getAccessor) { + if (member.kind === 138 && !getAccessor) { getAccessor = member; } - if (member.kind === 138 && !setAccessor) { + if (member.kind === 139 && !setAccessor) { setAccessor = member; } } @@ -4785,22 +5079,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156: - case 157: - case 159: case 158: + case 159: + case 161: case 160: - case 154: case 162: - case 155: - case 175: - case 163: + case 156: + case 164: + case 157: + case 177: + case 165: case 65: case 9: case 7: case 8: case 10: - case 172: + case 174: case 80: case 89: case 93: @@ -4816,6 +5110,12 @@ var ts; return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 && + node.parent.token === 79 && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isSupportedExpressionWithTypeArguments(node) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } @@ -4824,7 +5124,7 @@ var ts; if (node.kind === 65) { return true; } - else if (node.kind === 156) { + else if (node.kind === 158) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -4832,8 +5132,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 && node.parent.right === node) || - (node.parent.kind === 156 && node.parent.name === node); + return (node.parent.kind === 128 && node.parent.right === node) || + (node.parent.kind === 158 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -4960,6 +5260,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -5030,9 +5336,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129) { + if (d && d.kind === 130) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205) { return current; } } @@ -5044,7 +5350,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252); + var nodeConstructors = new Array(254); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5082,20 +5388,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127: + case 128: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129: + case 130: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130: + case 131: + case 134: case 133: - case 132: - case 225: - case 226: - case 199: - case 153: + case 227: + case 228: + case 201: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5104,24 +5410,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: + case 142: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 163: - case 201: - case 164: + case 139: + case 165: + case 203: + case 166: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5132,263 +5438,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142: + case 144: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145: - return visitNode(cbNode, node.exprName); - case 146: - return visitNodes(cbNodes, node.members); + case 143: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); case 147: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 148: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 149: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 150: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 151: + return visitNodes(cbNodes, node.types); case 152: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 153: case 154: return visitNodes(cbNodes, node.elements); - case 155: - return visitNodes(cbNodes, node.properties); case 156: + return visitNodes(cbNodes, node.elements); + case 157: + return visitNodes(cbNodes, node.properties); + case 158: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157: + case 159: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158: - case 159: + case 160: + case 161: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160: + case 162: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161: + case 163: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 165: - return visitNode(cbNode, node.expression); - case 166: + case 164: return visitNode(cbNode, node.expression); case 167: return visitNode(cbNode, node.expression); case 168: + return visitNode(cbNode, node.expression); + case 169: + return visitNode(cbNode, node.expression); + case 170: return visitNode(cbNode, node.operand); - case 173: + case 175: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169: + case 171: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171: + case 173: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174: + case 176: return visitNode(cbNode, node.expression); - case 180: - case 207: + case 182: + case 209: return visitNodes(cbNodes, node.statements); - case 228: + case 230: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181: + case 183: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200: + case 202: return visitNodes(cbNodes, node.declarations); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 184: + case 186: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185: + case 187: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187: + case 189: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 189: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 190: - case 191: - return visitNode(cbNode, node.label); - case 192: - return visitNode(cbNode, node.expression); - case 193: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 191: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 192: + case 193: + return visitNode(cbNode, node.label); case 194: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 208: - return visitNodes(cbNodes, node.clauses); - case 221: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 222: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 195: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 210: + return visitNodes(cbNodes, node.clauses); + case 223: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 224: + return visitNodes(cbNodes, node.statements); case 197: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 198: + return visitNode(cbNode, node.expression); + case 199: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224: + case 226: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131: + case 132: return visitNode(cbNode, node.expression); - case 202: - case 175: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 203: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 204: + case 177: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 207: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 229: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209: + case 211: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210: + case 212: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211: + case 213: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212: + case 214: return visitNode(cbNode, node.name); - case 213: - case 217: + case 215: + case 219: return visitNodes(cbNodes, node.elements); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214: - case 218: + case 216: + case 220: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172: + case 174: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128: + case 129: return visitNode(cbNode, node.expression); - case 223: + case 225: return visitNodes(cbNodes, node.types); - case 177: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220: + case 222: return visitNode(cbNode, node.expression); - case 219: + case 221: return visitNodes(cbNodes, node.decorators); - case 229: - return visitNode(cbNode, node.type); - case 233: - return visitNodes(cbNodes, node.types); - case 234: - return visitNodes(cbNodes, node.types); - case 232: - return visitNode(cbNode, node.elementType); - case 236: + case 231: return visitNode(cbNode, node.type); case 235: + return visitNodes(cbNodes, node.types); + case 236: + return visitNodes(cbNodes, node.types); + case 234: + return visitNode(cbNode, node.elementType); + case 238: return visitNode(cbNode, node.type); case 237: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 239: + return visitNodes(cbNodes, node.members); + case 241: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.type); - case 241: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); case 242: return visitNode(cbNode, node.type); case 243: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 244: return visitNode(cbNode, node.type); - case 238: + case 245: + return visitNode(cbNode, node.type); + case 246: + return visitNode(cbNode, node.type); + case 240: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245: - return visitNodes(cbNodes, node.tags); case 247: + return visitNodes(cbNodes, node.tags); + case 249: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248: - return visitNode(cbNode, node.typeExpression); - case 249: - return visitNode(cbNode, node.typeExpression); case 250: + return visitNode(cbNode, node.typeExpression); + case 251: + return visitNode(cbNode, node.typeExpression); + case 252: return visitNodes(cbNodes, node.typeParameters); } } @@ -5462,7 +5772,7 @@ var ts; sourceFile = createSourceFile(fileName, languageVersion); token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, true, parseSourceElement); + sourceFile.statements = parseList(0, parseStatement); ts.Debug.assert(token === 1); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -5483,9 +5793,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 181: - case 201: - case 130: + case 183: + case 203: + case 131: addJSDocComment(node); } forEachChild(node, visit); @@ -5523,7 +5833,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228, 0); + var sourceFile = createNode(230, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5541,9 +5851,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1); - } function setDisallowInContext(val) { setContextFlag(val, 2); } @@ -5614,9 +5921,6 @@ var ts; function inYieldContext() { return (contextFlags & 4) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8) !== 0; } @@ -5825,7 +6129,7 @@ var ts; return token === 8 || token === 7 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(128); + var node = createNode(129); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5879,23 +6183,21 @@ var ts; switch (parsingContext) { case 0: case 1: - return !(token === 22 && inErrorRecovery) && isStartOfModuleElement(); - case 2: - case 4: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); case 3: + return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + case 2: return token === 67 || token === 73; - case 5: + case 4: return isStartOfTypeMember(); - case 6: + case 5: return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); - case 7: + case 6: return token === 18 || isLiteralPropertyName(); - case 13: + case 12: return token === 18 || token === 35 || isLiteralPropertyName(); - case 10: + case 9: return isLiteralPropertyName(); - case 8: + case 7: if (token === 14) { return lookAhead(isValidHeritageClauseObjectLiteral); } @@ -5905,29 +6207,29 @@ var ts; else { return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9: + case 8: return isIdentifierOrPattern(); - case 11: + case 10: return token === 23 || token === 21 || isIdentifierOrPattern(); - case 16: - return isIdentifier(); - case 12: - case 14: - return token === 23 || token === 21 || isStartOfExpression(); case 15: + return isIdentifier(); + case 11: + case 13: + return token === 23 || token === 21 || isStartOfExpression(); + case 14: return isStartOfParameter(); + case 16: case 17: - case 18: return token === 23 || isStartOfType(); - case 19: + case 18: return isHeritageClause(); - case 20: + case 19: return isIdentifierOrKeyword(); + case 20: case 21: - case 22: - case 24: - return JSDocParser.isJSDocType(); case 23: + return JSDocParser.isJSDocType(); + case 22: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -5962,41 +6264,40 @@ var ts; switch (kind) { case 1: case 2: - case 3: + case 4: case 5: case 6: - case 7: - case 13: - case 10: - case 20: - return token === 15; - case 4: - return token === 15 || token === 67 || token === 73; - case 8: - return token === 14 || token === 79 || token === 102; - case 9: - return isVariableDeclaratorListTerminator(); - case 16: - return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; case 12: - return token === 17 || token === 22; - case 14: - case 18: - case 11: - return token === 19; - case 15: - return token === 17 || token === 19; - case 17: - return token === 25 || token === 16; + case 9: case 19: + return token === 15; + case 3: + return token === 15 || token === 67 || token === 73; + case 7: + return token === 14 || token === 79 || token === 102; + case 8: + return isVariableDeclaratorListTerminator(); + case 15: + return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; + case 11: + return token === 17 || token === 22; + case 13: + case 17: + case 10: + return token === 19; + case 14: + return token === 17 || token === 19; + case 16: + return token === 25 || token === 16; + case 18: return token === 14 || token === 15; - case 21: + case 20: return token === 17 || token === 51 || token === 15; - case 22: + case 21: return token === 25 || token === 15; - case 24: - return token === 19 || token === 15; case 23: + return token === 19 || token === 15; + case 22: return token === 15; } } @@ -6013,7 +6314,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 25; kind++) { + for (var kind = 0; kind < 24; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -6022,43 +6323,25 @@ var ts; } return false; } - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -6083,7 +6366,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 63; + var nodeContextFlags = node.parserContextFlags & 62; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -6099,61 +6382,47 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1: - return isReusableModuleElement(node); - case 6: - return isReusableClassMember(node); - case 3: - return isReusableSwitchClause(node); - case 2: - case 4: - return isReusableStatement(node); - case 7: - return isReusableEnumMember(node); case 5: + return isReusableClassMember(node); + case 2: + return isReusableSwitchClause(node); + case 0: + case 1: + case 3: + return isReusableStatement(node); + case 6: + return isReusableEnumMember(node); + case 4: return isReusableTypeMember(node); - case 9: - return isReusableVariableDeclaration(node); - case 15: - return isReusableParameter(node); - case 19: - case 16: - case 18: - case 17: - case 12: - case 13: case 8: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210: - case 209: - case 216: - case 215: - case 202: - case 203: - case 206: - case 205: - return true; - } - return isReusableStatement(node); + return isReusableVariableDeclaration(node); + case 14: + return isReusableParameter(node); + case 18: + case 15: + case 17: + case 16: + case 11: + case 12: + case 7: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136: - case 141: - case 135: case 137: + case 142: case 138: - case 133: - case 179: + case 139: + case 134: + case 181: return true; + case 136: + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 && + methodDeclaration.name.originalKeywordKind === 114; + return !nameIsConstructor; } } return false; @@ -6161,8 +6430,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221: - case 222: + case 223: + case 224: return true; } } @@ -6171,56 +6440,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201: - case 181: - case 180: - case 184: + case 203: case 183: - case 196: - case 192: - case 194: - case 191: - case 190: - case 188: - case 189: - case 187: - case 186: - case 193: case 182: - case 197: - case 195: + case 186: case 185: case 198: + case 194: + case 196: + case 193: + case 192: + case 190: + case 191: + case 189: + case 188: + case 195: + case 184: + case 199: + case 197: + case 187: + case 200: + case 212: + case 211: + case 218: + case 217: + case 208: + case 204: + case 205: + case 207: + case 206: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227; + return node.kind === 229; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140: - case 134: case 141: - case 132: - case 139: + case 135: + case 142: + case 133: + case 140: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199) { + if (node.kind !== 201) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130) { + if (node.kind !== 131) { return false; } var parameter = node; @@ -6238,29 +6516,28 @@ var ts; switch (context) { case 0: return ts.Diagnostics.Declaration_or_statement_expected; case 1: return ts.Diagnostics.Declaration_or_statement_expected; - case 2: return ts.Diagnostics.Statement_expected; - case 3: return ts.Diagnostics.case_or_default_expected; - case 4: return ts.Diagnostics.Statement_expected; - case 5: return ts.Diagnostics.Property_or_signature_expected; - case 6: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7: return ts.Diagnostics.Enum_member_expected; - case 8: return ts.Diagnostics.Expression_expected; - case 9: return ts.Diagnostics.Variable_declaration_expected; - case 10: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12: return ts.Diagnostics.Argument_expression_expected; - case 13: return ts.Diagnostics.Property_assignment_expected; - case 14: return ts.Diagnostics.Expression_or_comma_expected; - case 15: return ts.Diagnostics.Parameter_declaration_expected; - case 16: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_argument_expected; - case 18: return ts.Diagnostics.Type_expected; - case 19: return ts.Diagnostics.Unexpected_token_expected; - case 20: return ts.Diagnostics.Identifier_expected; - case 21: return ts.Diagnostics.Parameter_declaration_expected; - case 22: return ts.Diagnostics.Type_argument_expected; - case 24: return ts.Diagnostics.Type_expected; - case 23: return ts.Diagnostics.Property_assignment_expected; + case 2: return ts.Diagnostics.case_or_default_expected; + case 3: return ts.Diagnostics.Statement_expected; + case 4: return ts.Diagnostics.Property_or_signature_expected; + case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6: return ts.Diagnostics.Enum_member_expected; + case 7: return ts.Diagnostics.Expression_expected; + case 8: return ts.Diagnostics.Variable_declaration_expected; + case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11: return ts.Diagnostics.Argument_expression_expected; + case 12: return ts.Diagnostics.Property_assignment_expected; + case 13: return ts.Diagnostics.Expression_or_comma_expected; + case 14: return ts.Diagnostics.Parameter_declaration_expected; + case 15: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16: return ts.Diagnostics.Type_argument_expected; + case 17: return ts.Diagnostics.Type_expected; + case 18: return ts.Diagnostics.Unexpected_token_expected; + case 19: return ts.Diagnostics.Identifier_expected; + case 20: return ts.Diagnostics.Parameter_declaration_expected; + case 21: return ts.Diagnostics.Type_argument_expected; + case 23: return ts.Diagnostics.Type_expected; + case 22: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -6319,7 +6596,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(127, entity.pos); + var node = createNode(128, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6327,7 +6604,7 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); @@ -6336,7 +6613,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172); + var template = createNode(174); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -6349,7 +6626,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178); + var span = createNode(180); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -6382,22 +6659,30 @@ var ts; } return node; } - function parseTypeReference() { - var node = createNode(142); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 && token === 117 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145); + var node = createNode(147); parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129); + var node = createNode(130); node.name = parseIdentifier(); if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6411,7 +6696,7 @@ var ts; } function parseTypeParameters() { if (token === 24) { - return parseBracketedList(16, parseTypeParameter, 24, 25); + return parseBracketedList(15, parseTypeParameter, 24, 25); } } function parseParameterType() { @@ -6432,7 +6717,7 @@ var ts; } } function parseParameter() { - var node = createNode(130); + var node = createNode(131); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); @@ -6466,7 +6751,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15, parseParameter); + var result = parseDelimitedList(14, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17) && requireCompleteParameterList) { @@ -6484,7 +6769,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140) { + if (kind === 141) { parseExpected(88); } fillSignature(51, false, false, node); @@ -6524,10 +6809,10 @@ var ts; return token === 51 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141, fullStart); + var node = createNode(142, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15, parseParameter, 18, 19); + node.parameters = parseBracketedList(14, parseParameter, 18, 19); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6537,7 +6822,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(134, fullStart); + var method = createNode(135, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -6545,7 +6830,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132, fullStart); + var property = createNode(133, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6587,14 +6872,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(139); + return parseSignatureMember(140); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140); + return parseSignatureMember(141); } case 8: case 7: @@ -6624,14 +6909,14 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(146); + var node = createNode(148); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14)) { - members = parseList(5, false, parseTypeMember); + members = parseList(4, parseTypeMember); parseExpected(15); } else { @@ -6640,12 +6925,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148); - node.elementTypes = parseBracketedList(18, parseType, 18, 19); + var node = createNode(150); + node.elementTypes = parseBracketedList(17, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150); + var node = createNode(152); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6653,7 +6938,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144) { + if (kind === 146) { parseExpected(88); } fillSignature(32, false, false, node); @@ -6666,12 +6951,12 @@ var ts; function parseNonArrayType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99: return parseTokenNode(); case 97: @@ -6683,16 +6968,16 @@ var ts; case 16: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 97: case 14: @@ -6714,7 +6999,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(147, type.pos); + var node = createNode(149, type.pos); node.elementType = type; type = finishNode(node); } @@ -6729,7 +7014,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149, type.pos); + var node = createNode(151, type.pos); node.types = types; type = finishNode(node); } @@ -6774,10 +7059,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143); + return parseFunctionOrConstructorType(145); } if (token === 88) { - return parseFunctionOrConstructorType(144); + return parseFunctionOrConstructorType(146); } return parseUnionTypeOrHigher(); } @@ -6898,10 +7183,7 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -6910,7 +7192,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6924,8 +7206,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164, identifier.pos); - var parameter = createNode(130, identifier.pos); + var node = createNode(166, identifier.pos); + var parameter = createNode(131, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7003,7 +7285,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164); + var node = createNode(166); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -7031,7 +7313,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(171, leftOperand.pos); + var node = createNode(173, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -7044,7 +7326,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 126; + return t === 86 || t === 127; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7105,33 +7387,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170, left.pos); + var node = createNode(172, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168); + var node = createNode(170); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165); + var node = createNode(167); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166); + var node = createNode(168); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167); + var node = createNode(169); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7161,7 +7443,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169, expression.pos); + var node = createNode(171, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7184,14 +7466,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(156, expression.pos); + var node = createNode(158, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161); + var node = createNode(163); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -7202,7 +7484,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(156, expression.pos); + var propertyAccess = createNode(158, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7210,7 +7492,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(157, expression.pos); + var indexedAccess = createNode(159, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7224,7 +7506,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(160, expression.pos); + var tagExpression = createNode(162, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -7243,7 +7525,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7251,7 +7533,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7262,7 +7544,7 @@ var ts; } function parseArgumentList() { parseExpected(16); - var result = parseDelimitedList(12, parseArgumentExpression); + var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); return result; } @@ -7270,7 +7552,7 @@ var ts; if (!parseOptional(24)) { return undefined; } - var typeArguments = parseDelimitedList(17, parseType); + var typeArguments = parseDelimitedList(16, parseType); if (!parseExpected(25)) { return undefined; } @@ -7341,42 +7623,42 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174); + var node = createNode(176); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(176) : + token === 23 ? createNode(178) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154); + var node = createNode(156); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; - node.elements = parseDelimitedList(14, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13, parseArgumentOrArrayLiteralElement); parseExpected(19); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116)) { - return parseAccessorDeclaration(137, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(121)) { return parseAccessorDeclaration(138, fullStart, decorators, modifiers); } + else if (parseContextualModifier(122)) { + return parseAccessorDeclaration(139, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7396,13 +7678,13 @@ var ts; return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226, fullStart); + var shorthandDeclaration = createNode(228, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225, fullStart); + var propertyAssignment = createNode(227, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -7411,12 +7693,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155); + var node = createNode(157); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; } - node.properties = parseDelimitedList(13, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(15); return finishNode(node); } @@ -7425,7 +7707,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163); + var node = createNode(165); parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -7440,7 +7722,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -7449,10 +7731,10 @@ var ts; } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2, checkForStrictMode, parseStatement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -7467,7 +7749,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -7475,12 +7757,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182); + var node = createNode(184); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(184); + var node = createNode(186); parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7490,7 +7772,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185); + var node = createNode(187); parseExpected(75); node.statement = parseStatement(); parseExpected(100); @@ -7501,7 +7783,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186); + var node = createNode(188); parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7524,21 +7806,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86)) { - var forInStatement = createNode(188, pos); + var forInStatement = createNode(190, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126)) { - var forOfStatement = createNode(189, pos); + else if (parseOptional(127)) { + var forOfStatement = createNode(191, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187, pos); + var forStatement = createNode(189, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7556,7 +7838,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 ? 66 : 71); + parseExpected(kind === 193 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7564,7 +7846,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -7573,7 +7855,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193); + var node = createNode(195); parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7582,32 +7864,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221); + var node = createNode(223); parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222); + var node = createNode(224); parseExpected(73); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194); + var node = createNode(196); parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(208, scanner.getStartPos()); + var caseBlock = createNode(210, scanner.getStartPos()); parseExpected(14); - caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(15); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -7615,35 +7897,35 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(196); + var node = createNode(198); parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(197); + var node = createNode(199); parseExpected(96); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 ? parseCatchClause() : undefined; if (!node.catchClause || token === 81) { parseExpected(81); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224); + var result = createNode(226); parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198); + var node = createNode(200); parseExpected(72); parseSemicolon(); return finishNode(node); @@ -7652,13 +7934,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(195, fullStart); + var labeledStatement = createNode(197, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183, fullStart); + var expressionStatement = createNode(185, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -7671,7 +7953,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98: @@ -7680,28 +7966,30 @@ var ts; case 83: case 69: case 77: - return 1; + return true; case 103: - case 124: - nextToken(); - return isIdentifierOrKeyword() ? 1 : 0; - case 117: + case 125: + return nextTokenIsIdentifierOnSameLine(); case 118: + case 119: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115: nextToken(); - return isIdentifierOrKeyword() || token === 8 ? 2 : 0; + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85: nextToken(); return token === 8 || token === 35 || - token === 14 || isIdentifierOrKeyword() ? - 2 : 0; + token === 14 || isIdentifierOrKeyword(); case 78: nextToken(); if (token === 53 || token === 35 || token === 14 || token === 73) { - return 2; + return true; } continue; - case 115: case 108: case 106: case 107: @@ -7709,14 +7997,14 @@ var ts; nextToken(); continue; default: - return 0; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52: case 22: @@ -7740,56 +8028,39 @@ var ts; case 72: case 68: case 81: - return 1; + return true; case 70: case 78: case 85: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115: case 103: - case 117: case 118: - case 124: - return getDeclarationFlags() || 1; + case 119: + case 125: + return true; case 108: case 106: case 107: case 109: - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 : 1); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 : 0; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 || token === 18); + return isIdentifier() || token === 14 || token === 18; } function isLetDeclaration() { - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1); - } - function parseModuleElement() { - return parseModuleElementOfKind(3); - } - function parseSourceElement() { - return parseModuleElementOfKind(3); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22: return parseEmptyStatement(); case 14: - return parseBlock(false, false); + return parseBlock(false); case 98: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104: @@ -7810,9 +8081,9 @@ var ts; case 82: return parseForOrForInOrForOfStatement(); case 71: - return parseBreakOrContinueStatement(190); + return parseBreakOrContinueStatement(192); case 66: - return parseBreakOrContinueStatement(191); + return parseBreakOrContinueStatement(193); case 90: return parseReturnStatement(); case 101: @@ -7829,20 +8100,20 @@ var ts; return parseDebuggerStatement(); case 52: return parseDeclaration(); - case 70: + case 103: + case 125: + case 118: + case 119: case 115: + case 70: case 77: case 78: case 85: - case 103: - case 117: - case 118: case 106: case 107: case 108: case 109: - case 124: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -7864,12 +8135,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124: + case 125: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117: case 118: + case 119: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -7879,8 +8150,8 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { - var node = createMissingNode(219, true, ts.Diagnostics.Declaration_expected); + if (decorators || modifiers) { + var node = createMissingNode(221, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -7888,6 +8159,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 && canParseSemicolon()) { parseSemicolon(); @@ -7897,16 +8172,16 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(176); + return createNode(178); } - var node = createNode(153); + var node = createNode(155); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153); + var node = createNode(155); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 51) { @@ -7921,16 +8196,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151); + var node = createNode(153); parseExpected(14); - node.elements = parseDelimitedList(10, parseObjectBindingElement); + node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152); + var node = createNode(154); parseExpected(18); - node.elements = parseDelimitedList(11, parseArrayBindingElement); + node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(19); return finishNode(node); } @@ -7947,7 +8222,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199); + var node = createNode(201); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7956,7 +8231,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200); + var node = createNode(202); switch (token) { case 98: break; @@ -7970,13 +8245,13 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 126 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9, parseVariableDeclaration); + node.declarations = parseDelimitedList(8, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -7985,7 +8260,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181, fullStart); + var node = createNode(183, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7993,7 +8268,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(203, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83); @@ -8004,7 +8279,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136, pos); + var node = createNode(137, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114); @@ -8013,7 +8288,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135, fullStart); + var method = createNode(136, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8024,7 +8299,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133, fullStart); + var property = createNode(134, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8093,7 +8368,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 121 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 122 || idToken === 116) { return true; } switch (token) { @@ -8120,7 +8395,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131, decoratorStart); + var decorator = createNode(132, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8153,7 +8428,7 @@ var ts; } function parseClassElement() { if (token === 22) { - var result = createNode(179); + var result = createNode(181); nextToken(); return finishNode(result); } @@ -8177,21 +8452,19 @@ var ts; token === 18) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { var name_6 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 175); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 177); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -8208,9 +8481,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -8224,23 +8495,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19, false, parseHeritageClause); + return parseList(18, parseHeritageClause); } function parseHeritageClause() { if (token === 79 || token === 102) { - var node = createNode(223); + var node = createNode(225); node.token = token; nextToken(); - node.types = parseDelimitedList(8, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177); + var node = createNode(179); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } @@ -8248,10 +8519,10 @@ var ts; return token === 79 || token === 102; } function parseClassMembers() { - return parseList(6, false, parseClassElement); + return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103); @@ -8262,30 +8533,31 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124); + parseExpected(125); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(229, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { - node.members = parseDelimitedList(7, parseEnumMember); + node.members = parseDelimitedList(6, parseEnumMember); parseExpected(15); } else { @@ -8294,9 +8566,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207, scanner.getStartPos()); + var node = createNode(209, scanner.getStartPos()); if (parseExpected(14)) { - node.statements = parseList(1, false, parseModuleElement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -8305,7 +8577,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -8316,7 +8588,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8325,11 +8597,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118)) { + if (parseOptional(119)) { flags |= 32768; } else { - parseExpected(117); + parseExpected(118); if (token === 8) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8337,7 +8609,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 && + return token === 120 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -8346,7 +8618,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 125; + token === 126; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85); @@ -8354,8 +8626,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 125) { - var importEqualsDeclaration = createNode(209, fullStart); + if (token !== 23 && token !== 126) { + var importEqualsDeclaration = createNode(211, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -8365,14 +8637,14 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(210, fullStart); + var importDeclaration = createNode(212, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125); + parseExpected(126); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -8385,13 +8657,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211, fullStart); + var importClause = createNode(213, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(213); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(215); } return finishNode(importClause); } @@ -8401,8 +8673,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220); - parseExpected(119); + var node = createNode(222); + parseExpected(120); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -8416,7 +8688,7 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(212); + var namespaceImport = createNode(214); parseExpected(35); parseExpected(111); namespaceImport.name = parseIdentifier(); @@ -8424,14 +8696,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 213 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(19, kind === 215 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218); + return parseImportOrExportSpecifier(220); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214); + return parseImportOrExportSpecifier(216); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8450,22 +8722,22 @@ var ts; else { node.name = identifierName; } - if (kind === 214 && checkIdentifierIsKeyword) { + if (kind === 216 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(125); + parseExpected(126); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217); - if (parseOptional(125)) { + node.exportClause = parseNamedImportsOrExports(219); + if (parseOptional(126)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8473,7 +8745,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53)) { @@ -8538,15 +8810,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 209 && node.moduleReference.kind === 220 - || node.kind === 210 - || node.kind === 215 - || node.kind === 216 + || node.kind === 211 && node.moduleReference.kind === 222 + || node.kind === 212 + || node.kind === 217 + || node.kind === 218 ? node : undefined; }); @@ -8581,7 +8853,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(229); + var result = createNode(231); parseExpected(14); result.type = parseJSDocTopLevelType(); parseExpected(15); @@ -8592,12 +8864,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44) { - var unionType = createNode(233, type.pos); + var unionType = createNode(235, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53) { - var optionalType = createNode(240, type.pos); + var optionalType = createNode(242, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -8608,20 +8880,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18) { - var arrayType = createNode(232, type.pos); + var arrayType = createNode(234, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19); type = finishNode(arrayType); } else if (token === 50) { - var nullableType = createNode(235, type.pos); + var nullableType = createNode(237, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46) { - var nonNullableType = createNode(236, type.pos); + var nonNullableType = createNode(238, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -8655,40 +8927,40 @@ var ts; case 93: return parseJSDocThisType(); case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244); + var result = createNode(246); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243); + var result = createNode(245); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242); + var result = createNode(244); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241); + var result = createNode(243); nextToken(); parseExpected(16); - result.parameters = parseDelimitedList(21, parseJSDocParameter); + result.parameters = parseDelimitedList(20, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17); if (token === 51) { @@ -8698,18 +8970,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130); + var parameter = createNode(131); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240, type.pos); + var result = createNode(242, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239); + var result = createNode(241); result.name = parseSimplePropertyName(); while (parseOptional(20)) { if (token === 24) { @@ -8724,7 +8996,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(22, parseJSDocType); + var typeArguments = parseDelimitedList(21, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25); @@ -8738,21 +9010,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127, left.pos); + var result = createNode(128, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237); + var result = createNode(239); nextToken(); - result.members = parseDelimitedList(23, parseJSDocRecordMember); + result.members = parseDelimitedList(22, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238); + var result = createNode(240); result.name = parseSimplePropertyName(); if (token === 51) { nextToken(); @@ -8761,15 +9033,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236); + var result = createNode(238); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234); + var result = createNode(236); nextToken(); - result.types = parseDelimitedList(24, parseJSDocType); + result.types = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19); return finishNode(result); @@ -8781,7 +9053,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233); + var result = createNode(235); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17); @@ -8799,7 +9071,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230); + var result = createNode(232); nextToken(); return finishNode(result); } @@ -8812,11 +9084,11 @@ var ts; token === 25 || token === 53 || token === 44) { - var result = createNode(231, pos); + var result = createNode(233, pos); return finishNode(result); } else { - var result = createNode(235, pos); + var result = createNode(237, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -8887,7 +9159,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245, start); + var result = createNode(247, start); result.tags = tags; return finishNode(result, end); } @@ -8925,7 +9197,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246, atToken.pos); + var result = createNode(248, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -8977,7 +9249,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247, atToken.pos); + var result = createNode(249, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -8987,27 +9259,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248, atToken.pos); + var result = createNode(250, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249, atToken.pos); + var result = createNode(251, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9020,7 +9292,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129, name_7.pos); + var typeParameter = createNode(130, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9031,7 +9303,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250, atToken.pos); + var result = createNode(252, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9426,8 +9698,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -9443,10 +9715,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -9478,6 +9747,11 @@ var ts; flags: 2097152 } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { getDiagnostics(sourceFile); return emitResolver; @@ -9617,10 +9891,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228); + return ts.getAncestor(node, 230); } function isGlobalSourceFile(node) { - return node.kind === 228 && !ts.isExternalModule(node); + return node.kind === 230 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -9668,34 +9942,37 @@ var ts; } } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) break; - case 206: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 218)) { - break loop; + case 208: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 || + (location.kind === 208 && location.name.kind === 8)) { + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 && + ts.getDeclarationOfKind(moduleExports[name], 220)) { + break; } - result = undefined; - } - else if (location.kind === 228 || - (location.kind === 206 && location.name.kind === 8)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931)) { + break loop; + } break; - case 205: + case 207: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 134: case 133: - case 132: - if (location.parent.kind === 202 && !(location.flags & 128)) { + if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -9704,8 +9981,9 @@ var ts; } } break; - case 202: - case 203: + case 204: + case 177: + case 205: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -9713,29 +9991,36 @@ var ts; } break loop; } + if (location.kind === 177 && meaning & 32) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } break; - case 128: + case 129: grandparent = location.parent.parent; - if (grandparent.kind === 202 || grandparent.kind === 203) { + if (ts.isClassLike(grandparent) || grandparent.kind === 205) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 201: - case 164: + case 139: + case 203: + case 166: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163: + case 165: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -9748,17 +10033,8 @@ var ts; } } break; - case 175: - if (meaning & 32) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - case 131: - if (location.parent && location.parent.kind === 130) { + case 132: + if (location.parent && location.parent.kind === 131) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -9796,14 +10072,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 199); + var variableDeclaration = ts.getAncestor(declaration, 201); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 || - variableDeclaration.parent.parent.kind === 187) { + if (variableDeclaration.parent.parent.kind === 183 || + variableDeclaration.parent.parent.kind === 189) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 || - variableDeclaration.parent.parent.kind === 188) { + else if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 190) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -9825,10 +10101,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } - while (node && node.kind !== 210) { + while (node && node.kind !== 212) { node = node.parent; } return node; @@ -9838,7 +10114,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220) { + if (node.moduleReference.kind === 222) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -9927,17 +10203,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209: - return getTargetOfImportEqualsDeclaration(node); case 211: + return getTargetOfImportEqualsDeclaration(node); + case 213: return getTargetOfImportClause(node); - case 212: - return getTargetOfNamespaceImport(node); case 214: + return getTargetOfNamespaceImport(node); + case 216: return getTargetOfImportSpecifier(node); - case 218: + case 220: return getTargetOfExportSpecifier(node); - case 215: + case 217: return getTargetOfExportAssignment(node); } } @@ -9979,10 +10255,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215) { + if (node.kind === 217) { checkExpressionCached(node.expression); } - else if (node.kind === 218) { + else if (node.kind === 220) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -9992,17 +10268,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209); + importDeclaration = ts.getAncestor(entityName, 211); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 127) { + if (entityName.kind === 65 || entityName.parent.kind === 128) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 209); + ts.Debug.assert(entityName.parent.kind === 211); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10021,9 +10297,9 @@ var ts; return undefined; } } - else if (name.kind === 127 || name.kind === 156) { - var left = name.kind === 127 ? name.left : name.expression; - var right = name.kind === 127 ? name.right : name.name; + else if (name.kind === 128 || name.kind === 158) { + var left = name.kind === 128 ? name.left : name.expression; + var right = name.kind === 128 ? name.right : name.name; var namespace = resolveEntityName(left, 1536); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10168,7 +10444,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10233,17 +10509,17 @@ var ts; } } switch (location_1.kind) { - case 228: + case 230: if (!ts.isExternalModule(location_1)) { break; } - case 206: + case 208: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202: - case 203: + case 204: + case 205: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -10358,8 +10634,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 && declaration.name.kind === 8) || - (declaration.kind === 228 && ts.isExternalModule(declaration)); + return (declaration.kind === 208 && declaration.name.kind === 8) || + (declaration.kind === 230 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10391,11 +10667,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 145) { + if (entityName.parent.kind === 147) { meaning = 107455 | 1048576; } - else if (entityName.kind === 127 || entityName.kind === 156 || - entityName.parent.kind === 209) { + else if (entityName.kind === 128 || entityName.kind === 158 || + entityName.parent.kind === 211) { meaning = 1536; } else { @@ -10425,6 +10701,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -10439,10 +10722,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent; } - if (node.kind === 204) { + if (node.kind === 206) { return getSymbolOfNode(node); } } @@ -10450,15 +10733,24 @@ var ts; } var _displayBuilder; function getSymbolDisplayBuilder() { - function appendSymbolNameOnly(symbol, writer) { - if (symbol.declarations && symbol.declarations.length > 0) { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; if (declaration.name) { - writer.writeSymbol(ts.declarationNameToString(declaration.name), symbol); - return; + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 177: + return "(Anonymous class)"; + case 165: + case 166: + return "(Anonymous function)"; } } - writer.writeSymbol(symbol.name, symbol); + return symbol.name; + } + function appendSymbolNameOnly(symbol, writer) { + writer.writeSymbol(getNameOfSymbol(symbol), symbol); } function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { var parentSymbol; @@ -10649,7 +10941,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 || declaration.parent.kind === 207; + return declaration.parent.kind === 230 || declaration.parent.kind === 209; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -10723,7 +11015,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 123); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -10736,7 +11028,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -10779,7 +11071,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -10881,12 +11173,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206) { + if (node.kind === 208) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 228) { + else if (node.kind === 230) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10929,58 +11221,58 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153: + case 155: return isDeclarationVisible(node.parent.parent); - case 199: + case 201: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 206: - case 202: - case 203: + case 208: case 204: - case 201: case 205: - case 209: + case 206: + case 203: + case 207: + case 211: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 209 && parent_4.kind !== 228 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 && parent_4.kind !== 230 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 133: - case 132: - case 137: - case 138: - case 135: case 134: + case 133: + case 138: + case 139: + case 136: + case 135: if (node.flags & (32 | 64)) { return false; } - case 136: - case 140: - case 139: + case 137: case 141: - case 130: - case 207: - case 143: - case 144: - case 146: + case 140: case 142: - case 147: + case 131: + case 209: + case 145: + case 146: case 148: + case 144: case 149: case 150: + case 151: + case 152: return isDeclarationVisible(node.parent); - case 211: - case 212: + case 213: case 214: + case 216: return false; - case 129: - case 228: + case 130: + case 230: return true; - case 215: + case 217: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -10996,10 +11288,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215) { + if (node.parent && node.parent.kind === 217) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 220) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -11045,7 +11337,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 199 ? node.parent.parent.parent : node.parent; + return node.kind === 201 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11071,7 +11363,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var name_9 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_9.text) || isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1) || @@ -11108,10 +11400,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 188) { + if (declaration.parent.parent.kind === 190) { return anyType; } - if (declaration.parent.parent.kind === 189) { + if (declaration.parent.parent.kind === 191) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11120,10 +11412,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var func = declaration.parent; - if (func.kind === 138 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137); + if (func.kind === 139 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11136,7 +11428,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 226) { + if (declaration.kind === 228) { return checkIdentifier(declaration.name); } return undefined; @@ -11165,7 +11457,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11180,7 +11472,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 + return pattern.kind === 153 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11190,7 +11482,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 225 ? getWidenedType(type) : type; + return declaration.kind !== 227 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -11198,7 +11490,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -11211,10 +11503,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224) { + if (declaration.parent.kind === 226) { return links.type = anyType; } - if (declaration.kind === 215) { + if (declaration.kind === 217) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol)) { @@ -11242,7 +11534,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137) { + if (accessor.kind === 138) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -11258,8 +11550,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137); - var setter = ts.getDeclarationOfKind(symbol, 138); + var getter = ts.getDeclarationOfKind(symbol, 138); + var setter = ts.getDeclarationOfKind(symbol, 139); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11285,7 +11577,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137); + var getter_1 = ts.getDeclarationOfKind(symbol, 138); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -11374,9 +11666,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 || node.kind === 201 || - node.kind === 163 || node.kind === 135 || - node.kind === 164) { + if (node.kind === 204 || node.kind === 177 || + node.kind === 203 || node.kind === 165 || + node.kind === 136 || node.kind === 166) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -11385,14 +11677,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 ? 202 : 203; - return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205); + return appendOuterTypeParameters(undefined, declaration); } - function getLocalTypeParametersOfClassOrInterface(symbol) { + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 || node.kind === 202) { + if (node.kind === 205 || node.kind === 204 || + node.kind === 177 || node.kind === 206) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -11402,56 +11695,109 @@ var ts; return result; } function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 && getSignaturesOfType(type, 1).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128) { + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 | 2048))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 | 2048)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); @@ -11471,7 +11817,7 @@ var ts; var kind = symbol.flags & 32 ? 1024 : 2048; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -11491,9 +11837,16 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204); + var declaration = ts.getDeclarationOfKind(symbol, 206); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -11515,7 +11868,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11630,34 +11983,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -11756,10 +12117,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -11965,7 +12326,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -11987,22 +12348,31 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { - if (declaration.kind === 137 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138); + if (declaration.kind === 138 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -12013,19 +12383,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143: - case 144: - case 201: - case 135: - case 134: + case 145: + case 146: + case 203: case 136: - case 139: + case 135: + case 137: case 140: case 141: - case 137: + case 142: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12095,7 +12465,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 || signature.declaration.kind === 140; + var isConstructor = signature.declaration.kind === 137 || signature.declaration.kind === 141; var type = createObjectType(32768 | 131072); type.members = emptySymbols; type.properties = emptyArray; @@ -12109,7 +12479,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 120 : 122; + var syntaxKind = kind === 1 ? 121 : 123; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -12139,13 +12509,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130).parent); } function getTypeListId(types) { switch (types.length) { @@ -12192,18 +12562,18 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 && n.typeName.kind === 65) { + if (n.kind === 144 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); if (symbol && (symbol.flags & 262144)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -12217,55 +12587,71 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - if (node.kind !== 177 || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056); - if (symbol) { - if ((symbol.flags & 262144) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 | 2048) && type.flags & 4096) { - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), expectedTypeArgCount); - return undefined; - } - } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var typeNameOrExpression = node.kind === 144 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -12275,9 +12661,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202: - case 203: + case 204: case 205: + case 207: return declaration; } } @@ -12312,6 +12698,12 @@ var ts; function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } function createTypeFromGenericGlobalType(genericGlobalType, elementType) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; } @@ -12478,38 +12870,40 @@ var ts; switch (node.kind) { case 112: return anyType; - case 122: + case 123: return stringType; - case 120: + case 121: return numberType; case 113: return booleanType; - case 123: + case 124: return esSymbolType; case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 142: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145: - return getTypeFromTypeQueryNode(node); - case 147: - return getTypeFromArrayTypeNode(node); - case 148: - return getTypeFromTupleTypeNode(node); - case 149: - return getTypeFromUnionTypeNode(node); - case 150: - return getTypeFromTypeNode(node.type); - case 143: case 144: + return getTypeFromTypeReference(node); + case 143: + return booleanType; + case 179: + return getTypeFromTypeReference(node); + case 147: + return getTypeFromTypeQueryNode(node); + case 149: + return getTypeFromArrayTypeNode(node); + case 150: + return getTypeFromTupleTypeNode(node); + case 151: + return getTypeFromUnionTypeNode(node); + case 152: + return getTypeFromTypeNode(node.type); + case 145: case 146: + case 148: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 65: - case 127: + case 128: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -12599,11 +12993,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -12660,27 +13062,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163: - case 164: + case 165: + case 166: return isContextSensitiveFunctionLikeDeclaration(node); - case 155: + case 157: return ts.forEach(node.properties, isContextSensitive); - case 154: + case 156: return ts.forEach(node.elements, isContextSensitive); - case 171: + case 173: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170: + case 172: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225: + case 227: return isContextSensitive(node.initializer); + case 136: case 135: - case 134: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 164: return isContextSensitive(node.expression); } return false; @@ -12688,23 +13090,20 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } } return type; } - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -12720,8 +13119,8 @@ var ts; function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source, target, errorNode, headMessage) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); @@ -12955,9 +13354,9 @@ var ts; maybeStack[depth][id] = 1; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -12990,21 +13389,6 @@ var ts; } return result; } - function isDeeplyNestedGeneric(type, stack) { - if (type.flags & (4096 | 65536) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 | 65536) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -13175,6 +13559,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -13264,6 +13675,21 @@ var ts; return 0; } } + function isDeeplyNestedGeneric(type, stack, depth) { + if (type.flags & (4096 | 65536) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 | 65536) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0; } @@ -13454,22 +13880,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 134: case 133: - case 132: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130: + case 131: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201: + case 203: + case 136: case 135: - case 134: - case 137: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -13541,20 +13967,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -13612,22 +14024,26 @@ var ts; } else if (source.flags & 48128 && (target.flags & (4096 | 8192) || (target.flags & 32768) && target.symbol && target.symbol.flags & (8192 | 2048))) { - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; } } function inferFromProperties(source, target) { @@ -13652,7 +14068,14 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -13712,10 +14135,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 145: + case 147: return true; case 65: - case 127: + case 128: node = node.parent; continue; default: @@ -13757,7 +14180,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 162) { + while (n.kind === 164) { n = n.expression; } if (n.kind === 65 && getResolvedSymbol(n) === symbol) { @@ -13774,46 +14197,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170: + case 172: return isAssignedInBinaryExpression(node); - case 199: - case 153: - return isAssignedInVariableDeclaration(node); - case 151: - case 152: - case 154: + case 201: case 155: + return isAssignedInVariableDeclaration(node); + case 153: + case 154: case 156: case 157: case 158: case 159: + case 160: case 161: - case 162: - case 168: - case 165: - case 166: + case 163: + case 164: + case 170: case 167: + case 168: case 169: case 171: - case 174: - case 180: - case 181: + case 173: + case 176: + case 182: case 183: - case 184: case 185: case 186: case 187: case 188: case 189: - case 192: - case 193: + case 190: + case 191: case 194: - case 221: - case 222: case 195: case 196: - case 197: + case 223: case 224: + case 197: + case 198: + case 199: + case 226: return ts.forEachChild(node, isAssignedIn); } return false; @@ -13850,17 +14273,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184: + case 186: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171: + case 173: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170: + case 172: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -13870,14 +14293,14 @@ var ts; } } break; - case 228: - case 206: - case 201: - case 135: - case 134: - case 137: - case 138: + case 230: + case 208: + case 203: case 136: + case 135: + case 138: + case 139: + case 137: break loop; } if (narrowedType !== type) { @@ -13891,7 +14314,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 166 || expr.right.kind !== 8) { + if (expr.left.kind !== 168 || expr.right.kind !== 8) { return type; } var left = expr.left; @@ -13970,20 +14393,44 @@ var ts; } } if (targetType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + if (originalType.flags & 16384) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162: + case 160: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164: return narrowType(type, expr.expression, assumeTrue); - case 170: + case 172: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -13998,7 +14445,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168: + case 170: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -14009,7 +14456,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 && languageVersion < 2) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 && languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -14033,15 +14480,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 224) { + symbol.valueDeclaration.parent.kind === 226) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 200) { + while (container.kind !== 202) { container = container.parent; } container = container.parent; - if (container.kind === 181) { + if (container.kind === 183) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -14058,9 +14505,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 133 || container.kind === 136) { + if (container.kind === 134 || container.kind === 137) { + var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } else { @@ -14070,61 +14517,58 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 164) { + if (container.kind === 166) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 206: + case 208: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 205: + case 207: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 136: + case 137: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 134: case 133: - case 132: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128: + case 129: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; - if (classNode) { - var symbol = getSymbolOfNode(classNode); + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130) { + if (n.kind === 131) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -14132,31 +14576,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 136; + canUseSuperExpression = container.kind === 137; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 164) { + while (container && container.kind === 166) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } - if (container && container.parent && container.parent.kind === 202) { + if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || - container.kind === 138; + container.kind === 136 || + container.kind === 135 || + container.kind === 138 || + container.kind === 139; } else { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || + container.kind === 136 || + container.kind === 135 || container.kind === 138 || + container.kind === 139 || + container.kind === 134 || container.kind === 133 || - container.kind === 132 || - container.kind === 136; + container.kind === 137; } } } @@ -14164,13 +14608,13 @@ var ts; var returnType; if ((container.flags & 128) || isCallExpression) { getNodeLinks(node).flags |= 32; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -14180,7 +14624,7 @@ var ts; return returnType; } } - if (container && container.kind === 128) { + if (container && container.kind === 129) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -14218,7 +14662,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -14251,8 +14695,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 136 || - functionDecl.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138))) { + functionDecl.kind === 137 || + functionDecl.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -14271,7 +14715,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160) { + if (template.parent.kind === 162) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -14379,34 +14823,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: - case 153: + case 155: return getContextualTypeForInitializerExpression(node); - case 164: - case 192: + case 166: + case 194: return getContextualTypeForReturnExpression(node); - case 173: + case 175: return getContextualTypeForYieldOperand(parent); - case 158: - case 159: - return getContextualTypeForArgument(parent, node); + case 160: case 161: + return getContextualTypeForArgument(parent, node); + case 163: return getTypeFromTypeNode(parent.type); - case 170: + case 172: return getContextualTypeForBinaryOperand(node); - case 225: + case 227: return getContextualTypeForObjectLiteralElement(parent); - case 154: + case 156: return getContextualTypeForElementExpression(node); - case 171: + case 173: return getContextualTypeForConditionalOperand(node); - case 178: - ts.Debug.assert(parent.parent.kind === 172); + case 180: + ts.Debug.assert(parent.parent.kind === 174); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162: + case 164: return getContextualType(parent); } return undefined; @@ -14421,7 +14865,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 || node.kind === 164; + return node.kind === 165 || node.kind === 166; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -14429,7 +14873,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -14473,13 +14917,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 172 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (parent.kind === 225) { + if (parent.kind === 227) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154) { + if (parent.kind === 156) { return isAssignmentTarget(parent); } return false; @@ -14498,7 +14942,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174) { + if (inDestructuringPattern && e.kind === 176) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -14510,7 +14954,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174; + hasSpreadElement = hasSpreadElement || e.kind === 176; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -14521,7 +14965,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -14554,18 +14998,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 || - memberDecl.kind === 226 || + if (memberDecl.kind === 227 || + memberDecl.kind === 228 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225) { + if (memberDecl.kind === 227) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135) { + else if (memberDecl.kind === 136) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226); + ts.Debug.assert(memberDecl.kind === 228); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -14580,7 +15024,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 137 || memberDecl.kind === 138); + ts.Debug.assert(memberDecl.kind === 138 || memberDecl.kind === 139); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -14613,7 +15057,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133; + return s.valueDeclaration ? s.valueDeclaration.kind : 134; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -14623,7 +15067,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 202); + var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -14653,7 +15097,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -14670,7 +15114,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -14680,14 +15124,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 + var left = node.kind === 158 ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { return false; } else { @@ -14702,7 +15146,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 && node.parent.expression === node) { + if (node.parent.kind === 161 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -14798,10 +15242,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160) { + if (node.kind === 162) { checkExpression(node.template); } - else { + else if (node.kind !== 132) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -14851,7 +15295,8 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174) { + var arg = args[i]; + if (arg && arg.kind === 176) { return i; } } @@ -14861,11 +15306,13 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 160) { + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 162) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172) { + if (tagExpression.template.kind === 174) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -14877,22 +15324,27 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } + else if (node.kind === 132) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + } else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 159); + ts.Debug.assert(callExpression.kind === 161); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); } var hasRightNumberOfTypeArgs = !typeArguments || (signature.typeParameters && typeArguments.length === signature.typeParameters.length); if (!hasRightNumberOfTypeArgs) { return false; } - var spreadArgIndex = getSpreadArgumentIndex(args); if (spreadArgIndex >= 0) { return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1; } @@ -14919,7 +15371,7 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument, context) { + function inferTypeArguments(node, signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; var inferenceMapper = createInferenceMapper(context); for (var i = 0; i < typeParameters.length; i++) { @@ -14930,15 +15382,13 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); - var argType = void 0; - if (i === 0 && args[i].parent.kind === 160) { - argType = globalTemplateStringsArrayType; - } - else { + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); } @@ -14946,7 +15396,7 @@ var ts; } } if (excludeArgument) { - for (var i = 0; i < args.length; i++) { + for (var i = 0; i < argCount; i++) { if (excludeArgument[i] === false) { var arg = args[i]; var paramType = getTypeAtPosition(signature, i); @@ -14956,7 +15406,7 @@ var ts; } getInferredTypes(context); } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; for (var i = 0; i < typeParameters.length; i++) { @@ -14966,23 +15416,33 @@ var ts; if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); } } } return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); - var argType = i === 0 && node.kind === 160 - ? globalTemplateStringsArrayType - : arg.kind === 8 && !reportErrors + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { + argType = arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { + } + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } } @@ -14991,35 +15451,168 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 160) { + if (node.kind === 162) { var template = node.template; - args = [template]; - if (template.kind === 172) { + args = [undefined]; + if (template.kind === 174) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } + else if (node.kind === 132) { + return undefined; + } else { args = node.arguments || emptyArray; } return args; } - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91) { - var containingClass = ts.getAncestor(callExpression, 202); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 132) { + switch (node.parent.kind) { + case 204: + case 177: + return 1; + case 134: + return 2; + case 136: + case 138: + case 139: + return signature.parameters.length >= 3 ? 3 : 2; + case 131: + return 3; + } } else { - return callExpression.typeArguments; + return args.length; } } - function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160; + function getEffectiveDecoratorFirstArgumentType(node) { + switch (node.kind) { + case 204: + case 177: + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + case 131: + node = node.parent; + if (node.kind === 137) { + var classSymbol_1 = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol_1); + } + case 134: + case 136: + case 138: + case 139: + return getParentTypeOfClassElement(node); + default: + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + } + function getEffectiveDecoratorSecondArgumentType(node) { + switch (node.kind) { + case 204: + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + case 131: + node = node.parent; + if (node.kind === 137) { + return anyType; + } + case 134: + case 136: + case 138: + case 139: + var element = node; + switch (element.name.kind) { + case 65: + case 7: + case 8: + return getStringLiteralType(element.name); + case 129: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 2097152)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } + default: + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + } + function getEffectiveDecoratorThirdArgumentType(node) { + switch (node.kind) { + case 204: + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + case 131: + return numberType; + case 134: + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + case 136: + case 138: + case 139: + 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); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + function getEffectiveArgumentType(node, argIndex, arg) { + if (node.kind === 132) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 162) { + return globalTemplateStringsArrayType; + } + return undefined; + } + function getEffectiveArgument(node, args, argIndex) { + if (node.kind === 132 || + (argIndex === 0 && node.kind === 162)) { + return undefined; + } + return args[argIndex]; + } + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 132) { + return node.expression; + } + else if (argIndex === 0 && node.kind === 162) { + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 162; + var isDecorator = node.kind === 132; var typeArguments; - if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } @@ -15027,17 +15620,19 @@ var ts; var candidates = candidatesOutArray || []; reorderCandidates(signatures, candidates); if (!candidates.length) { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); var excludeArgument; - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); + if (!isDecorator) { + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; } - excludeArgument[i] = true; } } var candidateForArgumentError; @@ -15060,19 +15655,22 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } if (!produceDiagnostics) { for (var _i = 0; _i < candidates.length; _i++) { @@ -15083,6 +15681,14 @@ var ts; } } return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } function chooseOverload(candidates, relation) { for (var _i = 0; _i < candidates.length; _i++) { var originalCandidate = candidates[_i]; @@ -15103,7 +15709,7 @@ var ts; typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } @@ -15145,7 +15751,9 @@ var ts; if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -15222,19 +15830,57 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray); } + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 204: + case 177: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 131: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 134: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 136: + case 138: + case 139: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158) { + if (node.kind === 160) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159) { + else if (node.kind === 161) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160) { + else if (node.kind === 162) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } + else if (node.kind === 132) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } else { ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); } @@ -15247,12 +15893,12 @@ var ts; if (node.expression.kind === 91) { return voidType; } - if (node.kind === 159) { + if (node.kind === 161) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 && - declaration.kind !== 140 && - declaration.kind !== 144) { + declaration.kind !== 137 && + declaration.kind !== 141 && + declaration.kind !== 146) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -15299,7 +15945,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180) { + if (func.body.kind !== 182) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -15376,7 +16022,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196); + return (body.statements.length === 1) && (body.statements[0].kind === 198); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -15385,7 +16031,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182) { return; } var bodyBlock = func.body; @@ -15398,10 +16044,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165) { + checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; @@ -15427,14 +16073,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 && node.kind !== 134) { + if (produceDiagnostics && node.kind !== 136 && node.kind !== 135) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -15442,7 +16088,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180) { + if (node.body.kind === 182) { checkSourceElement(node.body); } else { @@ -15450,7 +16096,7 @@ var ts; if (node.type) { checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); } - checkFunctionExpressionBodies(node.body); + checkFunctionAndClassExpressionBodies(node.body); } } } @@ -15472,13 +16118,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 156: { + case 158: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 157: + case 159: return true; - case 162: + case 164: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -15487,11 +16133,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65: - case 156: { + case 158: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 157: { + case 159: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { @@ -15501,7 +16147,7 @@ var ts; } return false; } - case 162: + case 164: return isConstVariableReference(n.expression); default: return false; @@ -15518,10 +16164,7 @@ var ts; return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 65) { - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -15533,9 +16176,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - if ((node.operator === 38 || node.operator === 39)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33: @@ -15558,7 +16198,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -15626,7 +16265,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 || p.kind === 226) { + if (p.kind === 227 || p.kind === 228) { var name_12 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -15651,8 +16290,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -15677,7 +16316,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 172 && restExpression.operatorToken.kind === 53) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -15690,14 +16329,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154) { + if (target.kind === 156) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -15710,11 +16349,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 155 || node.left.kind === 154)) { + if (operator === 53 && (node.left.kind === 157 || node.left.kind === 156)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -15860,7 +16496,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 || current.kind === 175) { + else if (ts.isClassLike(current)) { return true; } current = parent; @@ -15921,14 +16557,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -15950,12 +16586,8 @@ var ts; return type; } function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } - function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 127) { + if (node.kind === 128) { type = checkQualifiedName(node); } else { @@ -15963,9 +16595,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 156 && node.parent.expression === node) || - (node.parent.kind === 157 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 127) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 && node.parent.expression === node) || + (node.parent.kind === 159 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 128) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -15991,60 +16623,59 @@ var ts; return booleanType; case 7: return checkNumericLiteral(node); - case 172: + case 174: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 154: - return checkArrayLiteral(node, contextualMapper); - case 155: - return checkObjectLiteral(node, contextualMapper); case 156: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 157: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 158: + return checkPropertyAccessExpression(node); case 159: - return checkCallExpression(node); + return checkIndexedAccess(node); case 160: - return checkTaggedTemplateExpression(node); case 161: - return checkTypeAssertion(node); + return checkCallExpression(node); case 162: - return checkExpression(node.expression, contextualMapper); - case 175: - return checkClassExpression(node); + return checkTaggedTemplateExpression(node); case 163: + return checkTypeAssertion(node); case 164: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); + case 177: + return checkClassExpression(node); case 165: - return checkDeleteExpression(node); - case 167: - return checkVoidExpression(node); + case 166: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 168: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 167: + return checkDeleteExpression(node); case 169: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 170: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 171: - return checkConditionalExpression(node, contextualMapper); - case 174: - return checkSpreadElementExpression(node, contextualMapper); - case 176: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 172: + return checkBinaryExpression(node, contextualMapper); case 173: + return checkConditionalExpression(node, contextualMapper); + case 176: + return checkSpreadElementExpression(node, contextualMapper); + case 178: + return undefinedType; + case 175: return checkYieldExpression(node); } return unknownType; } function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } @@ -16059,14 +16690,12 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -16081,32 +16710,106 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 || - node.kind === 201 || - node.kind === 163; + return node.kind === 136 || + node.kind === 203 || + node.kind === 165; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166: + case 140: + case 203: + case 165: + case 145: + case 136: + case 135: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { - if (node.kind === 141) { + if (node.kind === 142) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 || node.kind === 201 || node.kind === 144 || - node.kind === 139 || node.kind === 136 || - node.kind === 140) { + else if (node.kind === 145 || node.kind === 203 || node.kind === 146 || + node.kind === 140 || node.kind === 137 || + node.kind === 141) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 || + param.name.kind === 154) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 || + element.name.kind === 153) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140: + case 141: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139: + case 140: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -16128,7 +16831,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203) { + if (node.kind === 205) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -16143,7 +16846,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122: + case 123: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -16151,7 +16854,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120: + case 121: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -16188,17 +16891,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 && n.expression.kind === 91; + return n.kind === 160 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163: - case 201: - case 164: - case 155: return false; + case 165: + case 203: + case 166: + case 157: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -16206,12 +16909,12 @@ var ts; if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 && n.kind !== 201) { + else if (n.kind !== 165 && n.kind !== 203) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 && + return n.kind === 134 && !(n.flags & 128) && !!n.initializer; } @@ -16221,7 +16924,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -16237,13 +16940,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137) { + if (node.kind === 138) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 137 ? 138 : 137; + var otherKind = node.kind === 138 ? 139 : 138; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -16265,26 +16968,26 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -16328,9 +17031,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 || signatureDeclarationNode.kind === 140); - var signatureKind = signatureDeclarationNode.kind === 139 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 || signatureDeclarationNode.kind === 141); + var signatureKind = signatureDeclarationNode.kind === 140 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -16348,7 +17051,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -16421,7 +17124,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 135 || node.kind === 134); + ts.Debug.assert(node.kind === 136 || node.kind === 135); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -16448,11 +17151,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 || node.parent.kind === 146 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 || node.parent.kind === 148 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 201 || node.kind === 135 || node.kind === 134 || node.kind === 136) { + if (node.kind === 203 || node.kind === 136 || node.kind === 135 || node.kind === 137) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -16549,16 +17252,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203: + case 205: return 2097152; - case 206: + case 208: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 202: - case 205: + case 204: + case 207: return 2097152 | 1048576; - case 209: + case 211: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -16569,57 +17272,65 @@ var ts; } } function checkDecorator(node) { - var expression = node.expression; - var exprType = checkExpression(expression); + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; switch (node.parent.kind) { - case 202: + case 204: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); - checkTypeAssignableTo(exprType, classDecoratorType, node); + expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 133: - checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); + case 131: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 135: - case 137: + case 134: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 136: case 138: + case 139: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); - checkTypeAssignableTo(exprType, methodDecoratorType, node); - break; - case 130: - checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); break; } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 142) { + if (node && node.kind === 144) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 | 132 | 258))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133: + case 134: checkTypeNodeAsExpression(node.type); break; - case 130: + case 131: checkTypeNodeAsExpression(node.type); break; - case 135: - checkTypeNodeAsExpression(node.type); - break; - case 137: + case 136: checkTypeNodeAsExpression(node.type); break; case 138: + checkTypeNodeAsExpression(node.type); + break; + case 139: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -16642,43 +17353,40 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 202: + case 204: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135: + case 136: checkParameterTypeAnnotationsAsExpressions(node); + case 139: case 138: - case 137: - case 133: - case 130: + case 134: + case 131: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130) { + if (node.kind === 131) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 128) { + if (node.name && node.name.kind === 129) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -16708,12 +17416,12 @@ var ts; } } function checkBlock(node) { - if (node.kind === 180) { + if (node.kind === 182) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207) { - checkFunctionExpressionBodies(node); + if (ts.isFunctionBlock(node) || node.kind === 209) { + checkFunctionAndClassExpressionBodies(node); } } function checkCollisionWithArgumentsInGeneratedCode(node) { @@ -16730,19 +17438,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 || - node.kind === 132 || + if (node.kind === 134 || + node.kind === 133 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || - node.kind === 138) { + node.kind === 138 || + node.kind === 139) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -16772,7 +17480,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 202); + var enclosingClass = ts.getContainingClass(node); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } @@ -16790,11 +17498,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 206 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 208 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 228 && ts.isExternalModule(parent)) { + if (parent.kind === 230 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -16805,7 +17513,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 199 && !node.initializer) { + if (node.kind === 201 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -16815,15 +17523,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200); - var container = varDeclList.parent.kind === 181 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202); + var container = varDeclList.parent.kind === 183 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 180 && ts.isFunctionLike(container.parent) || - container.kind === 207 || - container.kind === 206 || - container.kind === 228); + (container.kind === 182 && ts.isFunctionLike(container.parent) || + container.kind === 209 || + container.kind === 208 || + container.kind === 230); if (!namesShareScope) { var name_13 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); @@ -16833,7 +17541,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130) { + if (ts.getRootDeclaration(node).kind !== 131) { return; } var func = ts.getContainingFunction(node); @@ -16842,7 +17550,7 @@ var ts; if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130) { + if (referencedSymbol.valueDeclaration.kind === 131) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -16860,10 +17568,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -16872,7 +17579,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 130 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -16900,9 +17607,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 && node.kind !== 132) { + if (node.kind !== 134 && node.kind !== 133) { checkExportsOnMergedDeclarations(node); - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -16931,7 +17638,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 || node.kind === 155) { + if (node.kind === 182 || node.kind === 157) { return true; } node = node.parent; @@ -16959,12 +17666,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200) { + if (node.initializer && node.initializer.kind === 202) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -16979,13 +17686,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -17000,7 +17707,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -17010,7 +17717,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -17172,7 +17879,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138))); + return !!(node.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -17184,31 +17891,28 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { return; } - if (func.kind === 138) { + if (func.kind === 139) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136) { + else if (func.kind === 137) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -17218,7 +17922,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 222 && !hasDuplicateDefaultClause) { + if (clause.kind === 224 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -17230,7 +17934,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221) { + if (produceDiagnostics && clause.kind === 223) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -17247,7 +17951,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 && current.label.text === node.label.text) { + if (current.kind === 197 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -17291,7 +17995,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -17311,7 +18014,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 202) { + if (type.flags & 1024 && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -17342,7 +18045,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 128 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -17387,15 +18090,17 @@ var ts; } } function checkClassExpression(node) { - grammarErrorOnNode(node, ts.Diagnostics.class_expressions_are_not_currently_supported); - ts.forEach(node.members, checkSourceElement); - return unknownType; + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); if (!node.name && !(node.flags & 256)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); checkDecorators(node); if (node.name) { @@ -17410,35 +18115,38 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -17453,7 +18161,6 @@ var ts; } }); } - ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -17520,7 +18227,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 || kind === 138; + return kind === 138 || kind === 139; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -17580,13 +18287,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -17606,7 +18313,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -17627,7 +18334,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -17663,7 +18370,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168: + case 170: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -17674,7 +18381,7 @@ var ts; case 47: return ~value; } return undefined; - case 170: + case 172: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -17699,11 +18406,11 @@ var ts; return undefined; case 7: return +e.text; - case 162: + case 164: return evalConstant(e.expression); case 65: - case 157: - case 156: + case 159: + case 158: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -17714,7 +18421,7 @@ var ts; } else { var expression; - if (e.kind === 157) { + if (e.kind === 159) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -17731,7 +18438,7 @@ var ts; if (current.kind === 65) { break; } - else if (current.kind === 156) { + else if (current.kind === 158) { current = current.expression; } else { @@ -17766,7 +18473,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -17788,7 +18495,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 205) { + if (declaration.kind !== 207) { return false; } var enumDeclaration = declaration; @@ -17811,8 +18518,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 || - (declaration.kind === 201 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 || + (declaration.kind === 203 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -17834,7 +18541,14 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -17856,13 +18570,13 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 202); + var mergedClass = ts.getDeclarationOfKind(symbol, 204); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048; } } - if (node.name.kind === 8) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -17875,10 +18589,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127) { + if (node.kind === 128) { node = node.left; } - else if (node.kind === 156) { + else if (node.kind === 158) { node = node.expression; } else { @@ -17894,9 +18608,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 ? + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -17915,7 +18629,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 ? + var message = node.kind === 220 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -17928,7 +18642,10 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -17938,7 +18655,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { checkImportBinding(importClause.namedBindings); } else { @@ -17949,7 +18666,10 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -17977,14 +18697,17 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -17996,6 +18719,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 && node.parent.kind !== 209 && node.parent.kind !== 208) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -18003,8 +18731,11 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 ? node.parent : node.parent.parent; - if (container.kind === 206 && container.name.kind === 65) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + return; + } + var container = node.parent.kind === 230 ? node.parent : node.parent.parent; + if (container.kind === 208 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -18028,10 +18759,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228) { + if (node.kind === 230) { return node.statements; } - if (node.kind === 206 && node.body.kind === 207) { + if (node.kind === 208 && node.body.kind === 209) { return node.body.statements; } return emptyArray; @@ -18056,170 +18787,178 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129: - return checkTypeParameter(node); case 130: + return checkTypeParameter(node); + case 131: return checkParameter(node); + case 134: case 133: - case 132: return checkPropertyDeclaration(node); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: - return checkSignatureDeclaration(node); case 141: return checkSignatureDeclaration(node); - case 135: - case 134: - return checkMethodDeclaration(node); - case 136: - return checkConstructorDeclaration(node); - case 137: - case 138: - return checkAccessorDeclaration(node); case 142: + return checkSignatureDeclaration(node); + case 136: + case 135: + return checkMethodDeclaration(node); + case 137: + return checkConstructorDeclaration(node); + case 138: + case 139: + return checkAccessorDeclaration(node); + case 144: return checkTypeReferenceNode(node); - case 145: - return checkTypeQuery(node); - case 146: - return checkTypeLiteral(node); + case 143: + return checkTypePredicate(node); case 147: - return checkArrayType(node); + return checkTypeQuery(node); case 148: - return checkTupleType(node); + return checkTypeLiteral(node); case 149: - return checkUnionType(node); + return checkArrayType(node); case 150: + return checkTupleType(node); + case 151: + return checkUnionType(node); + case 152: return checkSourceElement(node.type); - case 201: - return checkFunctionDeclaration(node); - case 180: - case 207: - return checkBlock(node); - case 181: - return checkVariableStatement(node); - case 183: - return checkExpressionStatement(node); - case 184: - return checkIfStatement(node); - case 185: - return checkDoStatement(node); - case 186: - return checkWhileStatement(node); - case 187: - return checkForStatement(node); - case 188: - return checkForInStatement(node); - case 189: - return checkForOfStatement(node); - case 190: - case 191: - return checkBreakOrContinueStatement(node); - case 192: - return checkReturnStatement(node); - case 193: - return checkWithStatement(node); - case 194: - return checkSwitchStatement(node); - case 195: - return checkLabeledStatement(node); - case 196: - return checkThrowStatement(node); - case 197: - return checkTryStatement(node); - case 199: - return checkVariableDeclaration(node); - case 153: - return checkBindingElement(node); - case 202: - return checkClassDeclaration(node); case 203: - return checkInterfaceDeclaration(node); - case 204: - return checkTypeAliasDeclaration(node); - case 205: - return checkEnumDeclaration(node); - case 206: - return checkModuleDeclaration(node); - case 210: - return checkImportDeclaration(node); - case 209: - return checkImportEqualsDeclaration(node); - case 216: - return checkExportDeclaration(node); - case 215: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 182: - checkGrammarStatementInAmbientContext(node); - return; + case 209: + return checkBlock(node); + case 183: + return checkVariableStatement(node); + case 185: + return checkExpressionStatement(node); + case 186: + return checkIfStatement(node); + case 187: + return checkDoStatement(node); + case 188: + return checkWhileStatement(node); + case 189: + return checkForStatement(node); + case 190: + return checkForInStatement(node); + case 191: + return checkForOfStatement(node); + case 192: + case 193: + return checkBreakOrContinueStatement(node); + case 194: + return checkReturnStatement(node); + case 195: + return checkWithStatement(node); + case 196: + return checkSwitchStatement(node); + case 197: + return checkLabeledStatement(node); case 198: + return checkThrowStatement(node); + case 199: + return checkTryStatement(node); + case 201: + return checkVariableDeclaration(node); + case 155: + return checkBindingElement(node); + case 204: + return checkClassDeclaration(node); + case 205: + return checkInterfaceDeclaration(node); + case 206: + return checkTypeAliasDeclaration(node); + case 207: + return checkEnumDeclaration(node); + case 208: + return checkModuleDeclaration(node); + case 212: + return checkImportDeclaration(node); + case 211: + return checkImportEqualsDeclaration(node); + case 218: + return checkExportDeclaration(node); + case 217: + return checkExportAssignment(node); + case 184: checkGrammarStatementInAmbientContext(node); return; - case 219: + case 200: + checkGrammarStatementInAmbientContext(node); + return; + case 221: return checkMissingDeclaration(node); } } - function checkFunctionExpressionBodies(node) { + function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 163: - case 164: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 165: + case 166: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case 177: + ts.forEach(node.members, checkSourceElement); + break; + case 136: case 135: - case 134: - ts.forEach(node.decorators, checkFunctionExpressionBodies); - ts.forEach(node.parameters, checkFunctionExpressionBodies); + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136: case 137: case 138: - case 201: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 139: + case 203: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 193: - checkFunctionExpressionBodies(node.expression); + case 195: + checkFunctionAndClassExpressionBodies(node.expression); break; - case 131: - case 130: - case 133: case 132: - case 151: - case 152: + case 131: + case 134: + case 133: case 153: case 154: case 155: - case 225: case 156: case 157: + case 227: case 158: case 159: case 160: - case 172: - case 178: case 161: case 162: - case 166: - case 167: - case 165: - case 168: - case 169: - case 170: - case 171: case 174: case 180: - case 207: - case 181: + case 163: + case 164: + case 168: + case 169: + case 167: + case 170: + case 171: + case 172: + case 173: + case 176: + case 182: + case 209: case 183: - case 184: case 185: case 186: case 187: @@ -18228,22 +18967,24 @@ var ts; case 190: case 191: case 192: + case 193: case 194: - case 208: - case 221: - case 222: - case 195: case 196: - case 197: + case 210: + case 223: case 224: + case 197: + case 198: case 199: - case 200: + case 226: + case 201: case 202: - case 205: - case 227: - case 215: - case 228: - ts.forEachChild(node, checkFunctionExpressionBodies); + case 204: + case 207: + case 229: + case 217: + case 230: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } } @@ -18255,13 +18996,16 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1)) { + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } checkGrammarSourceFile(node); emitExtends = false; emitDecorate = false; emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); - checkFunctionExpressionBodies(node); + checkFunctionAndClassExpressionBodies(node); if (ts.isExternalModule(node)) { checkExternalModuleExports(node); } @@ -18302,7 +19046,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 && node.parent.statement === node) { + if (node.parent.kind === 195 && node.parent.statement === node) { return true; } node = node.parent; @@ -18324,23 +19068,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) { break; } - case 206: + case 208: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 205: + case 207: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 202: - case 203: + case 177: + if (location.name) { + copySymbol(location.symbol, meaning); + } + case 204: + case 205: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 163: + case 165: if (location.name) { copySymbol(location.symbol, meaning); } @@ -18368,78 +19116,44 @@ var ts; } } } - if (isInsideWithStatementBody(location)) { - return []; - } - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 228: - if (!ts.isExternalModule(location)) - break; - case 206: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); - break; - case 205: - copySymbols(getSymbolOfNode(location).exports, meaning & 8); - break; - case 202: - case 203: - if (!(memberFlags & 128)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056); - } - break; - case 163: - if (location.name) { - copySymbol(location.symbol, meaning); - } - break; - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 && + return name.kind === 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129: - case 202: - case 203: + case 130: case 204: case 205: + case 206: + case 207: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127) { + while (node.parent && node.parent.kind === 128) { node = node.parent; } - return node.parent && node.parent.kind === 142; + return node.parent && node.parent.kind === 144; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156) { + while (node.parent && node.parent.kind === 158) { node = node.parent; } - return node.parent && node.parent.kind === 177; + return node.parent && node.parent.kind === 179; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127) { + while (nodeOnRightSide.parent.kind === 128) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215) { + if (nodeOnRightSide.parent.kind === 217) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -18451,10 +19165,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215) { + if (entityName.parent.kind === 217) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 156) { + if (entityName.kind !== 158) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -18463,7 +19177,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 ? 793056 : 1536; + var meaning = entityName.parent.kind === 179 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -18475,14 +19189,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156) { + else if (entityName.kind === 158) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127) { + else if (entityName.kind === 128) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -18491,10 +19205,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 ? 793056 : 1536; + var meaning = entityName.parent.kind === 144 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } + if (entityName.parent.kind === 143) { + return resolveEntityName(entityName, 1); + } return undefined; } function getSymbolInfo(node) { @@ -18505,14 +19222,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 + return node.parent.kind === 217 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65: - case 156: - case 127: + case 158: + case 128: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93: case 91: @@ -18520,7 +19237,7 @@ var ts; return type.symbol; case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136) { + if (constructorDeclaration && constructorDeclaration.kind === 137) { return constructorDeclaration.parent.symbol; } return undefined; @@ -18528,12 +19245,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 || node.parent.kind === 216) && + ((node.parent.kind === 212 || node.parent.kind === 218) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 157 && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -18547,7 +19264,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 226) { + if (location && location.kind === 228) { return resolveEntityName(location.name, 107455); } return undefined; @@ -18562,6 +19279,9 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); @@ -18591,6 +19311,12 @@ var ts; } return checkExpression(expr); } + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = createSymbolTable(getPropertiesOfType(type)); @@ -18620,81 +19346,81 @@ var ts; } return [symbol]; } - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - if (languageVersion >= 2) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211) { - var defaultKeyword; - if (languageVersion === 0) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - if (languageVersion >= 2 || compilerOptions.module === 4) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 || node.kind === 205) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576) { + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944) { + return undefined; + } + symbol = exportSymbol; } - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 230) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 || n.kind === 207) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182: + case 210: + case 189: + case 190: + case 191: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209: case 211: - case 212: + case 213: case 214: - case 218: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 216: + case 220: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 218: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215: + case 217: return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -18739,7 +19465,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227) { + if (node.kind === 229) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -18750,10 +19476,9 @@ var ts; } return undefined; } - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -18762,14 +19487,14 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { var type = getTypeFromTypeNode(node); if (type.flags & 16) { return "void 0"; @@ -18791,42 +19516,42 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; } return "Object"; } - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { if (node) { switch (node.kind) { case 99: return "void 0"; - case 150: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143: - case 144: + case 152: + return serializeTypeNode(node.type); + case 145: + case 146: return "Function"; - case 147: - case 148: + case 149: + case 150: return "Array"; case 113: return "Boolean"; - case 122: + case 123: case 8: return "String"; - case 120: + case 121: return "Number"; - case 142: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145: - case 146: - case 149: + case 144: + return serializeTypeReferenceNode(node); + case 147: + case 148: + case 151: case 112: break; default: @@ -18836,23 +19561,23 @@ var ts; } return "Object"; } - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { switch (node.kind) { - case 202: return "Function"; - case 133: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204: return "Function"; + case 134: return serializeTypeNode(node.type); + case 131: return serializeTypeNode(node.type); + case 138: return serializeTypeNode(node.type); + case 139: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; } return "void 0"; } - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 202) { + if (node.kind === 204) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -18867,19 +19592,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147) { + if (parameterType.kind === 149) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -18888,9 +19613,9 @@ var ts; } return emptyArray; } - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -18912,25 +19637,24 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 | 8388608, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 || (n.parent.kind === 199 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 || (n.parent.kind === 201 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 224; + symbol.valueDeclaration.parent.kind !== 226; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -18950,7 +19674,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -18964,7 +19691,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -18993,10 +19719,7 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -19015,105 +19738,6 @@ var ts; } anyArrayType = createArrayType(anyType); } - function isReservedWordInStrictMode(node) { - return (node.parserContextFlags & 1) && - (102 <= node.originalKeywordKind && node.originalKeywordKind <= 110); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - if (ts.getAncestor(identifier, 202) || ts.getAncestor(identifier, 175)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130: - case 199: - case 201: - case 129: - case 153: - case 203: - case 204: - case 205: - return checkGrammarIdentifierInStrictMode(name); - case 202: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - if (typeName.kind === 65) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127) { - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - if (expression && expression.kind === 65) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -19124,7 +19748,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 || node.kind === 138) { + else if (node.kind === 138 || node.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -19134,33 +19758,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137: case 138: - case 136: - case 133: - case 132: - case 135: + case 139: + case 137: case 134: - case 141: - case 206: - case 210: - case 209: - case 216: - case 215: - case 130: + case 133: + case 136: + case 135: + case 142: + case 208: + case 212: + case 211: + case 218: + case 217: + case 131: break; - case 202: - case 203: - case 181: - case 201: case 204: - if (node.modifiers && node.parent.kind !== 207 && node.parent.kind !== 228) { + case 205: + case 183: + case 203: + case 206: + if (node.modifiers && node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205: + case 207: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70) && - node.parent.kind !== 207 && node.parent.kind !== 228) { + node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -19196,7 +19820,7 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -19205,10 +19829,10 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; @@ -19221,10 +19845,10 @@ var ts; else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -19233,13 +19857,13 @@ var ts; if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -19247,7 +19871,7 @@ var ts; break; } } - if (node.kind === 136) { + if (node.kind === 137) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -19258,10 +19882,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 || node.kind === 209) && flags & 2) { + else if ((node.kind === 212 || node.kind === 211) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -19324,7 +19948,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164) { + if (node.kind === 166) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -19359,7 +19983,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 && parameter.type.kind !== 120) { + if (parameter.type.kind !== 123 && parameter.type.kind !== 121) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -19391,7 +20015,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176) { + if (arg.kind === 178) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -19462,19 +20086,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 172 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 || - node.kind === 163 || - node.kind === 135); + ts.Debug.assert(node.kind === 203 || + node.kind === 165 || + node.kind === 136); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -19486,9 +20110,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -19500,55 +20121,52 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 || - name_17.kind === 128) { - checkGrammarComputedPropertyName(name_17); + var name_15 = prop.name; + if (prop.kind === 178 || + name_15.kind === 129) { + checkGrammarComputedPropertyName(name_15); continue; } var currentKind = void 0; - if (prop.kind === 225 || prop.kind === 226) { + if (prop.kind === 227 || prop.kind === 228) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135) { + else if (prop.kind === 136) { currentKind = Property; } - else if (prop.kind === 137) { + else if (prop.kind === 138) { currentKind = GetAccessor; } - else if (prop.kind === 138) { + else if (prop.kind === 139) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -19557,24 +20175,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200) { + if (forInOrOfStatement.initializer.kind === 202) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -19597,10 +20215,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 && accessor.parameters.length) { + else if (kind === 138 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138) { + else if (kind === 139) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -19625,7 +20243,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -19635,7 +20253,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155) { + if (node.parent.kind === 157) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -19643,7 +20261,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -19654,22 +20272,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 189: + case 190: + case 191: case 187: case 188: - case 189: - case 185: - case 186: return true; - case 195: + case 197: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -19681,9 +20299,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195: + case 197: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 190 + var isMisplacedContinueLabel = node.kind === 192 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -19691,8 +20309,8 @@ var ts; return false; } break; - case 194: - if (node.kind === 191 && !node.label) { + case 196: + if (node.kind === 193 && !node.label) { return false; } break; @@ -19705,13 +20323,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -19723,17 +20341,16 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 || node.name.kind === 151) { + if (node.name.kind === 154 || node.name.kind === 153) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 && node.parent.parent.kind !== 189) { + if (node.parent.parent.kind !== 190 && node.parent.parent.kind !== 191) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -19750,8 +20367,7 @@ var ts; } } var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65) { @@ -19763,7 +20379,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -19780,15 +20396,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184: - case 185: case 186: - case 193: case 187: case 188: - case 189: - return false; case 195: + case 189: + case 190: + case 191: + return false; + case 197: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -19804,7 +20420,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168) { + if (expression.kind === 170) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -19823,7 +20439,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 128) { + if (node.name.kind === 129) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -19865,23 +20481,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -19893,18 +20492,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -19914,11 +20513,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - node.kind === 216 || - node.kind === 215 || + if (node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + node.kind === 218 || + node.kind === 217 || (node.flags & 2) || (node.flags & (1 | 256))) { return false; @@ -19928,7 +20527,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181) { + if (ts.isDeclaration(decl) || decl.kind === 183) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -19947,7 +20546,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 180 || node.parent.kind === 207 || node.parent.kind === 228) { + if (node.parent.kind === 182 || node.parent.kind === 209 || node.parent.kind === 230) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -19958,13 +20557,8 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 16384) { - if (node.parserContextFlags & 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 && languageVersion >= 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -19975,8 +20569,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -20028,7 +20620,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210); + ts.Debug.assert(aliasEmitInfo.node.kind === 212); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -20101,10 +20693,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199) { + if (declaration.kind === 201) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 || declaration.kind === 214 || declaration.kind === 211) { + else if (declaration.kind === 215 || declaration.kind === 216 || declaration.kind === 213) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -20115,7 +20707,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210) { + if (moduleElementEmitInfo.node.kind === 212) { moduleElementEmitInfo.isVisible = true; } else { @@ -20123,12 +20715,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -20216,39 +20808,39 @@ var ts; function emitType(type) { switch (type.kind) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 177: + case 179: return emitExpressionWithTypeArguments(type); - case 142: - return emitTypeReference(type); - case 145: - return emitTypeQuery(type); - case 147: - return emitArrayType(type); - case 148: - return emitTupleType(type); - case 149: - return emitUnionType(type); - case 150: - return emitParenType(type); - case 143: case 144: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 147: + return emitTypeQuery(type); + case 149: + return emitArrayType(type); + case 150: + return emitTupleType(type); + case 151: + return emitUnionType(type); + case 152: + return emitParenType(type); + case 145: case 146: + return emitSignatureDeclarationWithJsDocComments(type); + case 148: return emitTypeLiteral(type); case 65: return emitEntityName(type); - case 127: + case 128: return emitEntityName(type); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 209 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 211 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -20256,8 +20848,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 ? entityName.left : entityName.expression; - var right = entityName.kind === 127 ? entityName.right : entityName.name; + var left = entityName.kind === 128 ? entityName.left : entityName.expression; + var right = entityName.kind === 128 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -20266,7 +20858,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 156); + ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 158); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -20327,9 +20919,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -20370,10 +20962,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 || - (node.parent.kind === 228 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 || + (node.parent.kind === 230 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -20382,7 +20974,7 @@ var ts; }); } else { - if (node.kind === 210) { + if (node.kind === 212) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -20400,23 +20992,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201: - return writeFunctionDeclaration(node); - case 181: - return writeVariableStatement(node); case 203: - return writeInterfaceDeclaration(node); - case 202: - return writeClassDeclaration(node); - case 204: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 183: + return writeVariableStatement(node); case 205: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 204: + return writeClassDeclaration(node); case 206: + return writeTypeAliasDeclaration(node); + case 207: + return writeEnumDeclaration(node); + case 208: return writeModuleDeclaration(node); - case 209: + case 211: return writeImportEqualsDeclaration(node); - case 210: + case 212: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -20430,7 +21022,7 @@ var ts; if (node.flags & 256) { write("default "); } - else if (node.kind !== 203) { + else if (node.kind !== 205) { write("declare "); } } @@ -20474,7 +21066,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -20500,7 +21092,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -20549,9 +21141,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207) { + while (node.body.kind !== 209) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -20612,7 +21209,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 && (node.parent.flags & 32); + return node.parent.kind === 136 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -20622,15 +21219,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - (node.parent.parent && node.parent.parent.kind === 146)) { - ts.Debug.assert(node.parent.kind === 135 || - node.parent.kind === 134 || - node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.kind === 139 || - node.parent.kind === 140); + if (node.parent.kind === 145 || + node.parent.kind === 146 || + (node.parent.parent && node.parent.parent.kind === 148)) { + ts.Debug.assert(node.parent.kind === 136 || + node.parent.kind === 135 || + node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.kind === 140 || + node.parent.kind === 141); emitType(node.constraint); } else { @@ -20640,31 +21237,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 202: + case 204: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203: + case 205: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140: + case 141: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139: + case 140: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 136: case 135: - case 134: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201: + case 203: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -20694,7 +21291,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 202) { + if (node.parent.parent.kind === 204) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -20771,16 +21368,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 199 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 133 || node.kind === 132) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 || node.kind === 133) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 || node.kind === 132) && node.parent.kind === 146) { + if ((node.kind === 134 || node.kind === 133) && node.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -20789,14 +21386,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199) { + if (node.kind === 201) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 || node.kind === 132) { + else if (node.kind === 134 || node.kind === 133) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -20804,7 +21401,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -20830,7 +21427,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { elements.push(element); } } @@ -20896,7 +21493,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 137 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -20909,7 +21506,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 + return accessor.kind === 138 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -20918,7 +21515,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138) { + if (accessorWithTypeAnnotation.kind === 139) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -20964,17 +21561,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201) { + if (node.kind === 203) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135) { + else if (node.kind === 136) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201) { + if (node.kind === 203) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136) { + else if (node.kind === 137) { write("constructor"); } else { @@ -20991,11 +21588,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 140 || node.kind === 144) { + if (node.kind === 141 || node.kind === 146) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141) { + if (node.kind === 142) { write("["); } else { @@ -21004,20 +21601,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141) { + if (node.kind === 142) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 143 || node.kind === 144; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146) { + var isFunctionTypeOrConstructorType = node.kind === 145 || node.kind === 146; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 && !(node.flags & 32)) { + else if (node.kind !== 137 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -21028,23 +21625,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140: + case 141: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141: + case 142: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 136: case 135: - case 134: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21052,7 +21649,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21065,7 +21662,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201: + case 203: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21097,9 +21694,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.parent.kind === 146) { + if (node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -21115,22 +21712,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136: + case 137: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140: + case 141: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139: + case 140: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 136: case 135: - case 134: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21138,7 +21735,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21150,7 +21747,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201: + case 203: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21161,12 +21758,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 151) { + if (bindingPattern.kind === 153) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152) { + else if (bindingPattern.kind === 154) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -21185,10 +21782,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176) { + if (bindingElement.kind === 178) { write(" "); } - else if (bindingElement.kind === 153) { + else if (bindingElement.kind === 155) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -21211,39 +21808,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201: - case 206: - case 209: case 203: - case 202: - case 204: + case 208: + case 211: case 205: + case 204: + case 206: + case 207: return emitModuleElement(node, isModuleElementVisible(node)); - case 181: + case 183: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210: + case 212: return emitModuleElement(node, !node.importClause); - case 216: + case 218: return emitExportDeclaration(node); + case 137: case 136: case 135: - case 134: return writeFunctionDeclaration(node); - case 140: - case 139: case 141: + case 140: + case 142: return emitSignatureDeclarationWithJsDocComments(node); - case 137: case 138: + case 139: return emitAccessorDeclaration(node); + case 134: case 133: - case 132: return emitPropertyDeclaration(node); - case 227: + case 229: return emitEnumMemberDeclaration(node); - case 215: + case 217: return emitExportAssignment(node); - case 228: + case 230: return emitSourceFile(node); } } @@ -21289,7 +21886,7 @@ var ts; } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -21353,7 +21950,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -21413,9 +22009,9 @@ var ts; var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -21433,72 +22029,43 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65) { - var name_20 = node.name.text; - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForClassExpression() { + return makeUniqueName("class"); } function generateNameForNode(node) { switch (node.kind) { - case 201: - case 202: - case 175: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205: - generateNameForModuleOrEnum(node); - break; - case 210: - generateNameForImportDeclaration(node); - break; - case 216: - generateNameForExportDeclaration(node); - break; - case 215: - generateNameForExportAssignment(node); - break; + case 65: + return makeUniqueName(node.text); + case 208: + case 207: + return generateNameForModuleOrEnum(node); + case 212: + case 218: + return generateNameForImportOrExportDeclaration(node); + case 203: + case 204: + case 217: + return generateNameForExportDefault(); + case 177: + return generateNameForClassExpression(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -21522,7 +22089,7 @@ var ts; return; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; } @@ -21575,8 +22142,8 @@ var ts; var emittedLine = writer.getLine(); var emittedColumn = writer.getColumn(); if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -21630,8 +22197,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -21648,19 +22215,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 201 || - node.kind === 163 || + else if (node.kind === 203 || + node.kind === 165 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || node.kind === 138 || - node.kind === 206 || - node.kind === 202 || - node.kind === 205) { + node.kind === 139 || + node.kind === 208 || + node.kind === 204 || + node.kind === 207) { if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 128 - ? ts.getTextOfNode(name_22) + var name_19 = node.name; + scopeName = name_19.kind === 129 + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -21753,19 +22320,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228) { + if (node.kind !== 230) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -22003,10 +22570,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 172) { + if (node.template.kind === 174) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 + var needsParens = templateSpan.expression.kind === 172 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -22030,7 +22597,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 162 + var needsParens = templateSpan.expression.kind !== 164 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -22063,11 +22630,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158: - case 159: - return parent.expression === template; case 160: + case 161: + return parent.expression === template; case 162: + case 164: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -22075,7 +22642,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 170: + case 172: switch (expression.operatorToken.kind) { case 35: case 36: @@ -22087,8 +22654,8 @@ var ts; default: return -1; } + case 175: case 173: - case 171: return -1; default: return 1; @@ -22100,11 +22667,11 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153); + ts.Debug.assert(node.kind !== 155); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 128) { + else if (node.kind === 129) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -22132,75 +22699,122 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130: - case 199: - case 153: - case 133: + case 156: + case 172: + case 160: + case 223: + case 129: + case 173: case 132: - case 225: - case 226: + case 167: + case 187: + case 159: + case 217: + case 185: + case 179: + case 189: + case 190: + case 191: + case 186: + case 161: + case 164: + case 171: + case 170: + case 194: + case 228: + case 176: + case 196: + case 162: + case 180: + case 198: + case 163: + case 168: + case 169: + case 188: + case 195: + case 175: + return true; + case 155: + case 229: + case 131: case 227: - case 135: case 134: case 201: - case 137: - case 138: - case 163: - case 202: - case 203: - case 205: - case 206: - case 209: + return parent.initializer === node; + case 158: + return parent.expression === node; + case 166: + case 165: + return parent.body === node; case 211: - case 212: - return parent.name === node; - case 214: - case 218: - return parent.name === node || parent.propertyName === node; - case 191: - case 190: - case 215: - return false; - case 195: - return node.parent.label === node; + return parent.moduleReference === node; + case 128: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230) { + if (languageVersion < 2 && compilerOptions.module !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155: + case 204: + case 207: + case 201: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -22241,7 +22855,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -22272,11 +22886,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: - case 154: case 156: - case 157: case 158: - case 162: + case 159: + case 160: + case 164: return false; } return true; @@ -22293,17 +22907,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174) { + if (e.kind === 176) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174) { + while (i < length && elements[i].kind !== 176) { i++; } write("["); @@ -22326,7 +22940,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174; + return node.kind === 176; } function emitArrayLiteral(node) { var elements = node.elements; @@ -22387,7 +23001,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 || property.kind === 138) { + if (property.kind === 138 || property.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -22438,13 +23052,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225) { + if (property.kind === 227) { emit(property.initializer); } - else if (property.kind === 226) { + else if (property.kind === 228) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135) { + else if (property.kind === 136) { emitFunctionDeclaration(property); } else { @@ -22476,7 +23090,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128) { + if (properties[i].name.kind === 129) { numInitialNonComputedProperties = i; break; } @@ -22490,35 +23104,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170, startsOnNewLine); + var result = ts.createSynthesizedNode(172, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156); + var result = ts.createSynthesizedNode(158); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157); + var result = ts.createSynthesizedNode(159); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 161) { + while (expr.kind === 163) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 && + expr.kind !== 161 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(162); + var node = ts.createSynthesizedNode(164); node.expression = expr; return node; } @@ -22531,32 +23145,26 @@ var ts; if (languageVersion >= 2 && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - if (languageVersion < 2) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - write(": "); - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -22567,7 +23175,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -22597,7 +23205,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -22615,10 +23223,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174; }); + return ts.forEach(elements, function (e) { return e.kind === 176; }); } function skipParentheses(node) { - while (node.kind === 162 || node.kind === 161) { + while (node.kind === 164 || node.kind === 163) { node = node.expression; } return node; @@ -22639,12 +23247,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156) { + if (expr.kind === 158) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157) { + else if (expr.kind === 159) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -22685,7 +23293,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 158 && node.expression.expression.kind === 91; } if (superCall && languageVersion < 2) { write(".call("); @@ -22736,20 +23344,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164) { - if (node.expression.kind === 161) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166) { + if (node.expression.kind === 163) { var operand = node.expression.expression; - while (operand.kind == 161) { + while (operand.kind === 163) { operand = operand.expression; } - if (operand.kind !== 168 && - operand.kind !== 167 && - operand.kind !== 166 && - operand.kind !== 165 && + if (operand.kind !== 170 && operand.kind !== 169 && - operand.kind !== 159 && - !(operand.kind === 158 && node.parent.kind === 159) && - !(operand.kind === 163 && node.parent.kind === 158)) { + operand.kind !== 168 && + operand.kind !== 167 && + operand.kind !== 171 && + operand.kind !== 161 && + !(operand.kind === 160 && node.parent.kind === 161) && + !(operand.kind === 165 && node.parent.kind === 160)) { emit(operand); return; } @@ -22778,7 +23386,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 || node.parent.kind === 153); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 || node.parent.kind === 155); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -22792,7 +23400,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 168) { + if (node.operand.kind === 170) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -22835,10 +23443,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228) { + if (current.kind === 230) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207) { + else if (ts.isFunctionLike(current) || current.kind === 209) { return false; } else { @@ -22848,8 +23456,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 155 || node.left.kind === 154)) { - emitDestructuring(node, node.parent.kind === 183); + (node.left.kind === 157 || node.left.kind === 156)) { + emitDestructuring(node, node.parent.kind === 185); } else { var exportChanged = node.operatorToken.kind >= 53 && @@ -22896,7 +23504,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180) { + if (node && node.kind === 182) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -22911,12 +23519,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207) { - ts.Debug.assert(node.parent.kind === 206); + if (node.kind === 209) { + ts.Debug.assert(node.parent.kind === 208); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207) { + if (node.kind === 209) { emitTempDeclarations(true); } decreaseIndent(); @@ -22925,7 +23533,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180) { + if (node.kind === 182) { write(" "); emit(node); } @@ -22937,7 +23545,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164); + emitParenthesizedIf(node.expression, node.expression.kind === 166); write(";"); } function emitIfStatement(node) { @@ -22950,7 +23558,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 184) { + if (node.elseStatement.kind === 186) { write(" "); emit(node.elseStatement); } @@ -22962,7 +23570,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { write(" "); } else { @@ -23031,7 +23639,7 @@ var ts; var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 200) { + if (node.initializer && node.initializer.kind === 202) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -23052,13 +23660,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 189) { + if (languageVersion < 2 && node.kind === 191) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -23068,7 +23676,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188) { + if (node.kind === 190) { write(" in "); } else { @@ -23136,7 +23744,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -23158,7 +23766,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 154 || node.initializer.kind === 155) { + if (node.initializer.kind === 156 || node.initializer.kind === 157) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -23167,7 +23775,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { emitLines(node.statement.statements); } else { @@ -23179,7 +23787,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 ? 66 : 71, node.pos); + emitToken(node.kind === 193 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } @@ -23224,7 +23832,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221) { + if (node.kind === 223) { write("case "); emit(node.expression); write(":"); @@ -23279,7 +23887,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206); + } while (node && node.kind !== 208); return node; } function emitContainingModuleName(node) { @@ -23304,7 +23912,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(167); + var result = ts.createSynthesizedNode(169); result.expression = zero; return result; } @@ -23373,15 +23981,15 @@ var ts; function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 199) { + if (root.kind === 201) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130) { + else if (root.kind === 131) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170) { + if (root.kind === 172) { emitAssignmentExpression(root); } else { @@ -23392,8 +24000,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 || name.parent.kind === 153); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 || name.parent.kind === 155); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -23425,14 +24032,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(170); + var equals = ts.createSynthesizedNode(172); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171); + var cond = ts.createSynthesizedNode(173); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -23446,13 +24053,15 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65) { - return createElementAccessExpression(object, propName); + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158); + var call = ts.createSynthesizedNode(160); var sliceIdentifier = ts.createSynthesizedNode(65); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -23467,8 +24076,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 || p.kind === 226) { - var propName = (p.name); + if (p.kind === 227 || p.kind === 228) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -23480,8 +24089,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -23491,14 +24100,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154) { + else if (target.kind === 156) { emitArrayLiteralAssignment(target, value); } else { @@ -23512,14 +24121,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write(")"); } } @@ -23539,11 +24148,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176) { + else if (element.kind !== 178) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -23569,14 +24178,13 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 188 && - node.parent.parent.kind !== 189) { + node.parent.parent.kind !== 190 && + node.parent.parent.kind !== 191) { initializer = createVoidZero(); } } @@ -23594,7 +24202,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176) { + if (node.kind === 178) { return; } var name = node.name; @@ -23606,48 +24214,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 && node.parent.kind !== 153)) { + if (!node.parent || (node.parent.kind !== 201 && node.parent.kind !== 155)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - if (languageVersion >= 2 || - ts.nodeIsSynthesized(node) || - node.kind !== 65 || - (node.parent.kind !== 199 && node.parent.kind !== 153)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { - return; - } - var list = ts.getAncestor(node, 200); - if (list.parent.kind === 181) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228; - var isModuleLevelBinding = list.parent.parent.kind === 207; - var isFunctionLevelBinding = list.parent.parent.kind === 180 && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 228; + node.parent.kind === 230; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -23692,12 +24267,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); + var name_20 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -23785,12 +24360,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 && languageVersion >= 2; + return node.kind === 166 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -23801,10 +24376,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163) { + if (node.kind === 165) { return !!node.name; } - if (node.kind === 201) { + if (node.kind === 203) { return !!node.name || languageVersion < 2; } } @@ -23812,7 +24387,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { @@ -23832,10 +24407,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 201 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 203 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitTrailingComments(node); } } @@ -23882,7 +24457,7 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 180) { + else if (node.body.kind === 182) { emitBlockFunctionBody(node, node.body); } else { @@ -23907,10 +24482,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 161) { + while (current.kind === 163) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155); + emitParenthesizedIf(body, current.kind === 157); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -23982,9 +24557,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183) { + if (statement && statement.kind === 185) { var expr = statement.expression; - if (expr && expr.kind === 158) { + if (expr && expr.kind === 160) { var func = expr.expression; if (func && func.kind === 91) { return statement; @@ -24015,7 +24590,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128) { + else if (memberName.kind === 129) { emitComputedPropertyName(memberName); } else { @@ -24027,7 +24602,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 134 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -24067,11 +24642,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179) { + if (member.kind === 181) { writeLine(); write(";"); } - else if (member.kind === 135 || node.kind === 134) { + else if (member.kind === 136 || node.kind === 135) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -24090,7 +24665,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 || member.kind === 138) { + else if (member.kind === 138 || member.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -24140,22 +24715,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 || node.kind === 134) && !member.body) { + if ((member.kind === 136 || node.kind === 135) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 || - member.kind === 137 || - member.kind === 138) { + else if (member.kind === 136 || + member.kind === 138 || + member.kind === 139) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 137) { + if (member.kind === 138) { write("get "); } - else if (member.kind === 138) { + else if (member.kind === 139) { write("set "); } if (member.asteriskToken) { @@ -24166,7 +24741,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179) { + else if (member.kind === 181) { writeLine(); write(";"); } @@ -24187,10 +24762,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 136 && !member.body) { + if (member.kind === 137 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 133 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 134 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -24290,7 +24865,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202) { + if (node.kind === 204) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { write("export "); @@ -24307,7 +24882,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -24374,7 +24949,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202) { + if (node.kind === 204) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -24432,11 +25007,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202) { + if (node.kind === 204) { write(";"); } emitEnd(node); - if (node.kind === 202) { + if (node.kind === 204) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -24510,13 +25085,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 135) { + if (member.kind === 136) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 133) { + if (member.kind !== 134) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24546,7 +25121,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133) { + if (member.kind !== 134) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24585,26 +25160,26 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 135: - case 137: + case 136: case 138: - case 133: + case 139: + case 134: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 135: + case 136: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 202: - case 135: - case 138: + case 204: + case 136: + case 139: return true; } return false; @@ -24613,7 +25188,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -24626,7 +25201,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -24644,7 +25219,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -24740,7 +25315,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -24774,7 +25349,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206) { + if (moduleDeclaration.body.kind === 208) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -24809,7 +25384,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207) { + if (node.body.kind === 209) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -24848,7 +25423,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -24866,16 +25441,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 && node.importClause && !!node.importClause.name; + return node.kind === 212 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -24902,7 +25477,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -24928,7 +25503,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 211 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -24940,7 +25515,7 @@ var ts; write(" = "); } else { - var isNakedImport = 210 && !node.importClause; + var isNakedImport = 212 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -25096,8 +25671,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 && - expression.kind !== 202) { + if (expression.kind !== 203 && + expression.kind !== 204) { write(";"); } emitEnd(node); @@ -25133,18 +25708,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210: + case 212: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 209: - if (node.moduleReference.kind === 220 && resolver.isReferencedAliasDeclaration(node)) { + case 211: + if (node.moduleReference.kind === 222 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 216: + case 218: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -25157,12 +25732,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215: + case 217: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -25182,13 +25757,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -25206,8 +25784,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 216 || - (importNode.kind === 210 && !importNode.importClause); + var skipNode = importNode.kind === 218 || + (importNode.kind === 212 && !importNode.importClause); if (skipNode) { continue; } @@ -25232,7 +25810,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 && externalImport.exportClause) { + if (externalImport.kind === 218 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -25261,7 +25839,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216) { + if (externalImport.kind !== 218) { continue; } var exportDecl = externalImport; @@ -25331,11 +25909,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 + var name_22 = local.kind === 65 ? local : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); + if (name_22) { + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -25346,7 +25924,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 || local.kind === 206 || local.kind === 205) { + if (local.kind === 204 || local.kind === 208 || local.kind === 207) { emitDeclarationName(local); } else { @@ -25380,21 +25958,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 201) { + if (node.kind === 203) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202) { + if (node.kind === 204) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205) { + if (node.kind === 207) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25403,7 +25981,7 @@ var ts; } return; } - if (node.kind === 206) { + if (node.kind === 208) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25412,17 +25990,17 @@ var ts; } return; } - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65) { + var name_23 = node.name; + if (name_23.kind === 65) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -25441,7 +26019,7 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 12288) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228; + ts.getEnclosingBlockScopeContainer(node).kind === 230; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); @@ -25458,10 +26036,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -25476,27 +26054,27 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210: + case 212: if (!importNode.importClause) { break; } - case 209: + case 211: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 + var defaultName = importNode.kind === 212 ? importNode.importClause.name : importNode.name; if (defaultName) { emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 && + if (importNode.kind === 212 && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { emitExportMemberAssignments(namedBindings.name); writeLine(); } @@ -25510,7 +26088,7 @@ var ts; } decreaseIndent(); break; - case 216: + case 218: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -25544,10 +26122,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 216: - case 210: - case 209: - case 201: + case 218: + case 212: + case 211: + case 203: continue; } writeLine(); @@ -25561,7 +26139,11 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -25634,8 +26216,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -25764,7 +26346,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -25775,48 +26357,47 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 203: - case 201: - case 210: - case 209: - case 204: - case 215: - return false; - case 181: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206: - return shouldEmitModuleDeclaration(node); case 205: + case 203: + case 212: + case 211: + case 206: + case 217: + return false; + case 183: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 208: + return shouldEmitModuleDeclaration(node); + case 207: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 180 && + if (node.kind !== 182 && node.parent && - node.parent.kind === 164 && + node.parent.kind === 166 && node.parent.body === node && compilerOptions.target <= 1) { return false; } return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { switch (node.kind) { case 65: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130: + return emitIdentifier(node); + case 131: return emitParameter(node); + case 136: case 135: - case 134: return emitMethod(node); - case 137: case 138: + case 139: return emitAccessor(node); case 93: return emitThis(node); @@ -25836,131 +26417,131 @@ var ts; case 12: case 13: return emitLiteral(node); - case 172: - return emitTemplateExpression(node); - case 178: - return emitTemplateSpan(node); - case 127: - return emitQualifiedName(node); - case 151: - return emitObjectBindingPattern(node); - case 152: - return emitArrayBindingPattern(node); - case 153: - return emitBindingElement(node); - case 154: - return emitArrayLiteral(node); - case 155: - return emitObjectLiteral(node); - case 225: - return emitPropertyAssignment(node); - case 226: - return emitShorthandPropertyAssignment(node); - case 128: - return emitComputedPropertyName(node); - case 156: - return emitPropertyAccess(node); - case 157: - return emitIndexedAccess(node); - case 158: - return emitCallExpression(node); - case 159: - return emitNewExpression(node); - case 160: - return emitTaggedTemplateExpression(node); - case 161: - return emit(node.expression); - case 162: - return emitParenExpression(node); - case 201: - case 163: - case 164: - return emitFunctionDeclaration(node); - case 165: - return emitDeleteExpression(node); - case 166: - return emitTypeOfExpression(node); - case 167: - return emitVoidExpression(node); - case 168: - return emitPrefixUnaryExpression(node); - case 169: - return emitPostfixUnaryExpression(node); - case 170: - return emitBinaryExpression(node); - case 171: - return emitConditionalExpression(node); case 174: - return emitSpreadElementExpression(node); - case 173: - return emitYieldExpression(node); - case 176: - return; + return emitTemplateExpression(node); case 180: - case 207: - return emitBlock(node); - case 181: - return emitVariableStatement(node); - case 182: - return write(";"); - case 183: - return emitExpressionStatement(node); - case 184: - return emitIfStatement(node); - case 185: - return emitDoStatement(node); - case 186: - return emitWhileStatement(node); - case 187: - return emitForStatement(node); - case 189: - case 188: - return emitForInOrForOfStatement(node); - case 190: - case 191: - return emitBreakOrContinueStatement(node); - case 192: - return emitReturnStatement(node); - case 193: - return emitWithStatement(node); - case 194: - return emitSwitchStatement(node); - case 221: - case 222: - return emitCaseOrDefaultClause(node); - case 195: - return emitLabelledStatement(node); - case 196: - return emitThrowStatement(node); - case 197: - return emitTryStatement(node); - case 224: - return emitCatchClause(node); - case 198: - return emitDebuggerStatement(node); - case 199: - return emitVariableDeclaration(node); - case 175: - return emitClassExpression(node); - case 202: - return emitClassDeclaration(node); - case 203: - return emitInterfaceDeclaration(node); - case 205: - return emitEnumDeclaration(node); + return emitTemplateSpan(node); + case 128: + return emitQualifiedName(node); + case 153: + return emitObjectBindingPattern(node); + case 154: + return emitArrayBindingPattern(node); + case 155: + return emitBindingElement(node); + case 156: + return emitArrayLiteral(node); + case 157: + return emitObjectLiteral(node); case 227: - return emitEnumMember(node); - case 206: - return emitModuleDeclaration(node); - case 210: - return emitImportDeclaration(node); - case 209: - return emitImportEqualsDeclaration(node); - case 216: - return emitExportDeclaration(node); - case 215: - return emitExportAssignment(node); + return emitPropertyAssignment(node); case 228: + return emitShorthandPropertyAssignment(node); + case 129: + return emitComputedPropertyName(node); + case 158: + return emitPropertyAccess(node); + case 159: + return emitIndexedAccess(node); + case 160: + return emitCallExpression(node); + case 161: + return emitNewExpression(node); + case 162: + return emitTaggedTemplateExpression(node); + case 163: + return emit(node.expression); + case 164: + return emitParenExpression(node); + case 203: + case 165: + case 166: + return emitFunctionDeclaration(node); + case 167: + return emitDeleteExpression(node); + case 168: + return emitTypeOfExpression(node); + case 169: + return emitVoidExpression(node); + case 170: + return emitPrefixUnaryExpression(node); + case 171: + return emitPostfixUnaryExpression(node); + case 172: + return emitBinaryExpression(node); + case 173: + return emitConditionalExpression(node); + case 176: + return emitSpreadElementExpression(node); + case 175: + return emitYieldExpression(node); + case 178: + return; + case 182: + case 209: + return emitBlock(node); + case 183: + return emitVariableStatement(node); + case 184: + return write(";"); + case 185: + return emitExpressionStatement(node); + case 186: + return emitIfStatement(node); + case 187: + return emitDoStatement(node); + case 188: + return emitWhileStatement(node); + case 189: + return emitForStatement(node); + case 191: + case 190: + return emitForInOrForOfStatement(node); + case 192: + case 193: + return emitBreakOrContinueStatement(node); + case 194: + return emitReturnStatement(node); + case 195: + return emitWithStatement(node); + case 196: + return emitSwitchStatement(node); + case 223: + case 224: + return emitCaseOrDefaultClause(node); + case 197: + return emitLabelledStatement(node); + case 198: + return emitThrowStatement(node); + case 199: + return emitTryStatement(node); + case 226: + return emitCatchClause(node); + case 200: + return emitDebuggerStatement(node); + case 201: + return emitVariableDeclaration(node); + case 177: + return emitClassExpression(node); + case 204: + return emitClassDeclaration(node); + case 205: + return emitInterfaceDeclaration(node); + case 207: + return emitEnumDeclaration(node); + case 229: + return emitEnumMember(node); + case 208: + return emitModuleDeclaration(node); + case 212: + return emitImportDeclaration(node); + case 211: + return emitImportEqualsDeclaration(node); + case 218: + return emitExportDeclaration(node); + case 217: + return emitExportAssignment(node); + case 230: return emitSourceFileNode(node); } } @@ -25988,7 +26569,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -26000,7 +26581,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.end !== node.parent.end) { + if (node.parent.kind === 230 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -26178,7 +26759,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -26211,16 +26792,17 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -26230,11 +26812,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -26245,6 +26828,17 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -26274,8 +26868,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -26314,16 +26907,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -26357,14 +26948,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -26378,16 +26972,16 @@ var ts; } function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -26395,15 +26989,17 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; - filesByName[canonicalAbsolutePath] = file; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -26413,7 +27009,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -26431,7 +27027,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 || node.kind === 209 || node.kind === 216) { + if (node.kind === 212 || node.kind === 211 || node.kind === 218) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -26452,7 +27048,7 @@ var ts; } } } - else if (node.kind === 206 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 208 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -26710,9 +27306,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, diff --git a/bin/tsserver.js b/bin/tsserver.js index 71ff883dbce..b9b8ecc2ad1 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -31,6 +31,36 @@ var ts; /// var ts; (function (ts) { + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -498,7 +528,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); } @@ -1116,14 +1146,32 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1317,6 +1365,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, 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}'." }, @@ -1494,9 +1547,7 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } }; })(ts || (ts = {})); /// @@ -1526,7 +1577,7 @@ var ts; "false": 80, "finally": 81, "for": 82, - "from": 125, + "from": 126, "function": 83, "get": 116, "if": 84, @@ -1535,36 +1586,37 @@ var ts; "in": 86, "instanceof": 87, "interface": 103, + "is": 117, "let": 104, - "module": 117, - "namespace": 118, + "module": 118, + "namespace": 119, "new": 88, "null": 89, - "number": 120, + "number": 121, "package": 105, "private": 106, "protected": 107, "public": 108, - "require": 119, + "require": 120, "return": 90, - "set": 121, + "set": 122, "static": 109, - "string": 122, + "string": 123, "super": 91, "switch": 92, - "symbol": 123, + "symbol": 124, "this": 93, "throw": 94, "true": 95, "try": 96, - "type": 124, + "type": 125, "typeof": 97, "var": 98, "void": 99, "while": 100, "with": 101, "yield": 110, - "of": 126, + "of": 127, "{": 14, "}": 15, "(": 16, @@ -1767,6 +1819,25 @@ var ts; return ch >= 48 && ch <= 55; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + default: + return ch > 127; + } + } + ts.couldStartTrivia = couldStartTrivia; function skipTrivia(text, pos, stopAfterLineBreak) { while (true) { var ch = text.charCodeAt(pos); @@ -2229,7 +2300,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125) { + else if (text.charCodeAt(pos) === 125) { pos++; } else { @@ -2849,9 +2920,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, @@ -3152,7 +3228,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -3199,7 +3275,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228) { + while (node && node.kind !== 230) { node = node.parent; } return node; @@ -3288,15 +3364,15 @@ var ts; return current; } switch (current.kind) { - case 228: + case 230: + case 210: + case 226: case 208: - case 224: - case 206: - case 187: - case 188: case 189: + case 190: + case 191: return current; - case 180: + case 182: if (!isFunctionLike(current.parent)) { return current; } @@ -3307,9 +3383,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 && + declaration.kind === 201 && declaration.parent && - declaration.parent.kind === 224; + declaration.parent.kind === 226; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3345,22 +3421,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228: + case 230: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 199: - case 153: - case 202: - case 175: - case 203: - case 206: - case 205: - case 227: case 201: - case 163: + case 155: + case 204: + case 177: + case 205: + case 208: + case 207: + case 229: + case 203: + case 165: errorNode = node.name; break; } @@ -3382,11 +3458,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 && isConst(node); + return node.kind === 207 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 || isBindingPattern(node))) { + while (node && (node.kind === 155 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3394,14 +3470,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199) { + if (node.kind === 201) { node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 202) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181) { + if (node && node.kind === 183) { flags |= node.flags; } return flags; @@ -3416,11 +3492,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 && node.expression.kind === 8; + return node.kind === 185 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 130 || node.kind === 129) { + if (node.kind === 131 || node.kind === 130) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3439,68 +3515,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 <= node.kind && node.kind <= 150) { + if (144 <= node.kind && node.kind <= 152) { return true; } switch (node.kind) { case 112: - case 120: - case 122: - case 113: + case 121: case 123: + case 113: + case 124: return true; case 99: - return node.parent.kind !== 167; + return node.parent.kind !== 169; case 8: - return node.parent.kind === 130; - case 177: - return true; + return node.parent.kind === 131; + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 65: - if (node.parent.kind === 127 && node.parent.right === node) { + if (node.parent.kind === 128 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 && node.parent.name === node) { + else if (node.parent.kind === 158 && node.parent.name === node) { node = node.parent; } - case 127: - case 156: - ts.Debug.assert(node.kind === 65 || node.kind === 127 || node.kind === 156, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 128: + case 158: + ts.Debug.assert(node.kind === 65 || node.kind === 128 || node.kind === 158, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145) { + if (parent_1.kind === 147) { return false; } - if (142 <= parent_1.kind && parent_1.kind <= 150) { + if (144 <= parent_1.kind && parent_1.kind <= 152) { return true; } switch (parent_1.kind) { - case 177: - return true; - case 129: - return node === parent_1.constraint; - case 133: - case 132: + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); case 130: - case 199: - return node === parent_1.type; + return node === parent_1.constraint; + case 134: + case 133: + case 131: case 201: - case 163: - case 164: + return node === parent_1.type; + case 203: + case 165: + case 166: + case 137: case 136: case 135: - case 134: - case 137: case 138: - return node === parent_1.type; case 139: + return node === parent_1.type; case 140: case 141: + case 142: return node === parent_1.type; - case 161: + case 163: return node === parent_1.type; - case 158: - case 159: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 160: + case 161: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 162: return false; } } @@ -3511,23 +3587,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192: + case 194: return visitor(node); - case 208: - case 180: - case 184: - case 185: + case 210: + case 182: case 186: case 187: case 188: case 189: - case 193: - case 194: - case 221: - case 222: + case 190: + case 191: case 195: - case 197: + case 196: + case 223: case 224: + case 197: + case 199: + case 226: return ts.forEachChild(node, traverse); } } @@ -3537,22 +3613,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173: + case 175: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 207: case 205: - case 203: + case 208: case 206: case 204: - case 202: + case 177: return; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128) { + if (name_4 && name_4.kind === 129) { traverse(name_4.expression); return; } @@ -3567,14 +3644,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153: + case 155: + case 229: + case 131: case 227: - case 130: - case 225: + case 134: case 133: - case 132: - case 226: - case 199: + case 228: + case 201: return true; } } @@ -3582,38 +3659,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - if (node) { - switch (node.kind) { - case 137: - case 138: - return true; - } - } - return false; + return node && (node.kind === 138 || node.kind === 139); } ts.isAccessor = isAccessor; function isClassLike(node) { - if (node) { - return node.kind === 202 || node.kind === 175; - } + return node && (node.kind === 204 || node.kind === 177); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136: - case 163: - case 201: - case 164: - case 135: - case 134: case 137: + case 165: + case 203: + case 166: + case 136: + case 135: case 138: case 139: case 140: case 141: - case 143: - case 144: + case 142: + case 145: + case 146: return true; } } @@ -3621,11 +3689,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 && isFunctionLike(node.parent); + return node && node.kind === 182 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 && node.parent.kind === 155; + return node && node.kind === 136 && node.parent.kind === 157; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3637,6 +3705,15 @@ var ts; } } ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { while (true) { node = node.parent; @@ -3644,36 +3721,36 @@ var ts; return undefined; } switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 164: + case 166: if (!includeArrowFunctions) { continue; } - case 201: - case 163: - case 206: - case 133: - case 132: - case 135: + case 203: + case 165: + case 208: case 134: + case 133: case 136: + case 135: case 137: case 138: - case 205: - case 228: + case 139: + case 207: + case 230: return node; } } @@ -3685,40 +3762,40 @@ var ts; if (!node) return node; switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 201: - case 163: - case 164: + case 203: + case 165: + case 166: if (!includeFunctions) { continue; } - case 133: - case 132: - case 135: case 134: + case 133: case 136: + case 135: case 137: case 138: + case 139: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160) { + if (node.kind === 162) { return node.tag; } return node.expression; @@ -3726,40 +3803,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202: + case 204: return true; - case 133: - return node.parent.kind === 202; - case 130: - return node.parent.body && node.parent.parent.kind === 202; - case 137: + case 134: + return node.parent.kind === 204; + case 131: + return node.parent.body && node.parent.parent.kind === 204; case 138: - case 135: - return node.body && node.parent.kind === 202; + case 139: + case 136: + return node.body && node.parent.kind === 204; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202: + case 204: if (node.decorators) { return true; } return false; - case 133: - case 130: + case 134: + case 131: if (node.decorators) { return true; } return false; - case 137: + case 138: if (node.body && node.decorators) { return true; } return false; - case 135: - case 138: + case 136: + case 139: if (node.body && node.decorators) { return true; } @@ -3770,10 +3847,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202: + case 204: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135: - case 138: + case 136: + case 139: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3791,8 +3868,6 @@ var ts; case 95: case 80: case 9: - case 154: - case 155: case 156: case 157: case 158: @@ -3801,71 +3876,75 @@ var ts; case 161: case 162: case 163: - case 175: case 164: - case 167: case 165: + case 177: case 166: - case 168: case 169: + case 167: + case 168: case 170: case 171: - case 174: case 172: - case 10: - case 176: case 173: + case 176: + case 174: + case 10: + case 178: + case 175: return true; - case 127: - while (node.parent.kind === 127) { + case 128: + while (node.parent.kind === 128) { node = node.parent; } - return node.parent.kind === 145; + return node.parent.kind === 147; case 65: - if (node.parent.kind === 145) { + if (node.parent.kind === 147) { return true; } case 7: case 8: var parent_2 = node.parent; switch (parent_2.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: + case 229: case 227: - case 225: - case 153: + case 155: return parent_2.initializer === node; - case 183: - case 184: case 185: case 186: - case 192: - case 193: - case 194: - case 221: - case 196: - case 194: - return parent_2.expression === node; case 187: + case 188: + case 194: + case 195: + case 196: + case 223: + case 198: + case 196: + return parent_2.expression === node; + case 189: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202) || forStatement.condition === node || forStatement.incrementor === node; - case 188: - case 189: + case 190: + case 191: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202) || forInStatement.expression === node; - case 161: + case 163: return node === parent_2.expression; - case 178: + case 180: return node === parent_2.expression; - case 128: + case 129: return node === parent_2.expression; - case 131: + case 132: return true; + case 179: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -3882,7 +3961,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind === 220; + return node.kind === 211 && node.moduleReference.kind === 222; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3891,20 +3970,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind !== 220; + return node.kind === 211 && node.moduleReference.kind !== 222; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } - if (node.kind === 209) { + if (node.kind === 211) { var reference = node.moduleReference; - if (reference.kind === 220) { + if (reference.kind === 222) { return reference.expression; } } - if (node.kind === 216) { + if (node.kind === 218) { return node.moduleSpecifier; } } @@ -3912,15 +3991,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130: + case 131: return node.questionToken !== undefined; + case 136: case 135: - case 134: return node.questionToken !== undefined; - case 226: - case 225: + case 228: + case 227: + case 134: case 133: - case 132: return node.questionToken !== undefined; } } @@ -3928,9 +4007,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 && + return node.kind === 243 && node.parameters.length > 0 && - node.parameters[0].type.kind === 243; + node.parameters[0].type.kind === 245; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -3944,15 +4023,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249); + return getJSDocTag(node, 251); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248); + return getJSDocTag(node, 250); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250); + return getJSDocTag(node, 252); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -3961,7 +4040,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247) { + if (t.kind === 249) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -3980,12 +4059,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64) { - if (node.type && node.type.kind === 242) { + if (node.type && node.type.kind === 244) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242; + return paramTag.typeExpression.type.kind === 244; } } return node.dotDotDotToken !== undefined; @@ -4006,7 +4085,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 || node.kind === 151); + return !!node && (node.kind === 154 || node.kind === 153); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4021,33 +4100,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164: - case 153: - case 202: - case 136: - case 205: - case 227: - case 218: - case 201: - case 163: - case 137: - case 211: - case 209: - case 214: - case 203: - case 135: - case 134: - case 206: - case 212: - case 130: - case 225: - case 133: - case 132: - case 138: - case 226: + case 166: + case 155: case 204: - case 129: - case 199: + case 177: + case 137: + case 207: + case 229: + case 220: + case 203: + case 165: + case 138: + case 213: + case 211: + case 216: + case 205: + case 136: + case 135: + case 208: + case 214: + case 131: + case 227: + case 134: + case 133: + case 139: + case 228: + case 206: + case 130: + case 201: return true; } return false; @@ -4055,25 +4135,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191: - case 190: - case 198: - case 185: - case 183: - case 182: - case 188: - case 189: - case 187: - case 184: - case 195: - case 192: - case 194: - case 94: - case 197: - case 181: - case 186: case 193: - case 215: + case 192: + case 200: + case 187: + case 185: + case 184: + case 190: + case 191: + case 189: + case 186: + case 197: + case 194: + case 196: + case 94: + case 199: + case 183: + case 188: + case 195: + case 217: return true; default: return false; @@ -4082,13 +4162,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136: - case 133: - case 135: case 137: - case 138: case 134: - case 141: + case 136: + case 138: + case 139: + case 135: + case 142: return true; default: return false; @@ -4100,7 +4180,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 || parent.kind === 218) { + if (parent.kind === 216 || parent.kind === 220) { if (parent.propertyName) { return true; } @@ -4111,13 +4191,43 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134: + case 133: + case 136: + case 135: + case 138: + case 139: + case 229: + case 227: + case 158: + return parent.name === node; + case 128: + if (parent.right === node) { + while (parent.kind === 128) { + parent = parent.parent; + } + return parent.kind === 147; + } + return false; + case 155: + case 216: + return parent.propertyName === node; + case 220: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 209 || - node.kind === 211 && !!node.name || - node.kind === 212 || + return node.kind === 211 || + node.kind === 213 && !!node.name || node.kind === 214 || - node.kind === 218 || - node.kind === 215 && node.expression.kind === 65; + node.kind === 216 || + node.kind === 220 || + node.kind === 217 && node.expression.kind === 65; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4200,7 +4310,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 126; + return 66 <= token && token <= 127; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4209,19 +4319,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 && + declaration.name.kind === 129 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 && isESSymbolIdentifier(node.expression); + return node.kind === 158 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 128) { + if (name.kind === 129) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4256,18 +4366,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130; + return root.kind === 131; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153) { + while (node.kind === 155) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 || n.kind === 228; + return isFunctionLike(n) || n.kind === 208 || n.kind === 230; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4491,7 +4601,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 && nodeIsPresent(member.body)) { + if (member.kind === 137 && nodeIsPresent(member.body)) { return member; } }); @@ -4514,10 +4624,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137) { + if (accessor.kind === 138) { getAccessor = accessor; } - else if (accessor.kind === 138) { + else if (accessor.kind === 139) { setAccessor = accessor; } else { @@ -4526,7 +4636,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 || member.kind === 138) + if ((member.kind === 138 || member.kind === 139) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4537,10 +4647,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 && !getAccessor) { + if (member.kind === 138 && !getAccessor) { getAccessor = member; } - if (member.kind === 138 && !setAccessor) { + if (member.kind === 139 && !setAccessor) { setAccessor = member; } } @@ -4661,22 +4771,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156: - case 157: - case 159: case 158: + case 159: + case 161: case 160: - case 154: case 162: - case 155: - case 175: - case 163: + case 156: + case 164: + case 157: + case 177: + case 165: case 65: case 9: case 7: case 8: case 10: - case 172: + case 174: case 80: case 89: case 93: @@ -4692,6 +4802,12 @@ var ts; return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 && + node.parent.token === 79 && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isSupportedExpressionWithTypeArguments(node) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } @@ -4700,7 +4816,7 @@ var ts; if (node.kind === 65) { return true; } - else if (node.kind === 156) { + else if (node.kind === 158) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -4708,8 +4824,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 && node.parent.right === node) || - (node.parent.kind === 156 && node.parent.name === node); + return (node.parent.kind === 128 && node.parent.right === node) || + (node.parent.kind === 158 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -4836,6 +4952,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -4906,9 +5028,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129) { + if (d && d.kind === 130) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205) { return current; } } @@ -4920,7 +5042,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252); + var nodeConstructors = new Array(254); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4958,20 +5080,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127: + case 128: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129: + case 130: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130: + case 131: + case 134: case 133: - case 132: - case 225: - case 226: - case 199: - case 153: + case 227: + case 228: + case 201: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -4980,24 +5102,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: + case 142: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 163: - case 201: - case 164: + case 139: + case 165: + case 203: + case 166: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5008,263 +5130,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142: + case 144: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145: - return visitNode(cbNode, node.exprName); - case 146: - return visitNodes(cbNodes, node.members); + case 143: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); case 147: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 148: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 149: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 150: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 151: + return visitNodes(cbNodes, node.types); case 152: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 153: case 154: return visitNodes(cbNodes, node.elements); - case 155: - return visitNodes(cbNodes, node.properties); case 156: + return visitNodes(cbNodes, node.elements); + case 157: + return visitNodes(cbNodes, node.properties); + case 158: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157: + case 159: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158: - case 159: + case 160: + case 161: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160: + case 162: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161: + case 163: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 165: - return visitNode(cbNode, node.expression); - case 166: + case 164: return visitNode(cbNode, node.expression); case 167: return visitNode(cbNode, node.expression); case 168: + return visitNode(cbNode, node.expression); + case 169: + return visitNode(cbNode, node.expression); + case 170: return visitNode(cbNode, node.operand); - case 173: + case 175: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169: + case 171: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171: + case 173: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174: + case 176: return visitNode(cbNode, node.expression); - case 180: - case 207: + case 182: + case 209: return visitNodes(cbNodes, node.statements); - case 228: + case 230: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181: + case 183: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200: + case 202: return visitNodes(cbNodes, node.declarations); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 184: + case 186: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185: + case 187: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187: + case 189: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 189: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 190: - case 191: - return visitNode(cbNode, node.label); - case 192: - return visitNode(cbNode, node.expression); - case 193: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 191: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 192: + case 193: + return visitNode(cbNode, node.label); case 194: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 208: - return visitNodes(cbNodes, node.clauses); - case 221: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 222: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 195: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 210: + return visitNodes(cbNodes, node.clauses); + case 223: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 224: + return visitNodes(cbNodes, node.statements); case 197: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 198: + return visitNode(cbNode, node.expression); + case 199: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224: + case 226: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131: + case 132: return visitNode(cbNode, node.expression); - case 202: - case 175: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 203: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 204: + case 177: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 207: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 229: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209: + case 211: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210: + case 212: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211: + case 213: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212: + case 214: return visitNode(cbNode, node.name); - case 213: - case 217: + case 215: + case 219: return visitNodes(cbNodes, node.elements); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214: - case 218: + case 216: + case 220: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172: + case 174: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128: + case 129: return visitNode(cbNode, node.expression); - case 223: + case 225: return visitNodes(cbNodes, node.types); - case 177: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220: + case 222: return visitNode(cbNode, node.expression); - case 219: + case 221: return visitNodes(cbNodes, node.decorators); - case 229: - return visitNode(cbNode, node.type); - case 233: - return visitNodes(cbNodes, node.types); - case 234: - return visitNodes(cbNodes, node.types); - case 232: - return visitNode(cbNode, node.elementType); - case 236: + case 231: return visitNode(cbNode, node.type); case 235: + return visitNodes(cbNodes, node.types); + case 236: + return visitNodes(cbNodes, node.types); + case 234: + return visitNode(cbNode, node.elementType); + case 238: return visitNode(cbNode, node.type); case 237: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 239: + return visitNodes(cbNodes, node.members); + case 241: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.type); - case 241: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); case 242: return visitNode(cbNode, node.type); case 243: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 244: return visitNode(cbNode, node.type); - case 238: + case 245: + return visitNode(cbNode, node.type); + case 246: + return visitNode(cbNode, node.type); + case 240: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245: - return visitNodes(cbNodes, node.tags); case 247: + return visitNodes(cbNodes, node.tags); + case 249: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248: - return visitNode(cbNode, node.typeExpression); - case 249: - return visitNode(cbNode, node.typeExpression); case 250: + return visitNode(cbNode, node.typeExpression); + case 251: + return visitNode(cbNode, node.typeExpression); + case 252: return visitNodes(cbNodes, node.typeParameters); } } @@ -5338,7 +5464,7 @@ var ts; sourceFile = createSourceFile(fileName, languageVersion); token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, true, parseSourceElement); + sourceFile.statements = parseList(0, parseStatement); ts.Debug.assert(token === 1); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -5359,9 +5485,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 181: - case 201: - case 130: + case 183: + case 203: + case 131: addJSDocComment(node); } forEachChild(node, visit); @@ -5399,7 +5525,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228, 0); + var sourceFile = createNode(230, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5417,9 +5543,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1); - } function setDisallowInContext(val) { setContextFlag(val, 2); } @@ -5490,9 +5613,6 @@ var ts; function inYieldContext() { return (contextFlags & 4) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8) !== 0; } @@ -5701,7 +5821,7 @@ var ts; return token === 8 || token === 7 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(128); + var node = createNode(129); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5755,23 +5875,21 @@ var ts; switch (parsingContext) { case 0: case 1: - return !(token === 22 && inErrorRecovery) && isStartOfModuleElement(); - case 2: - case 4: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); case 3: + return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + case 2: return token === 67 || token === 73; - case 5: + case 4: return isStartOfTypeMember(); - case 6: + case 5: return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); - case 7: + case 6: return token === 18 || isLiteralPropertyName(); - case 13: + case 12: return token === 18 || token === 35 || isLiteralPropertyName(); - case 10: + case 9: return isLiteralPropertyName(); - case 8: + case 7: if (token === 14) { return lookAhead(isValidHeritageClauseObjectLiteral); } @@ -5781,29 +5899,29 @@ var ts; else { return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9: + case 8: return isIdentifierOrPattern(); - case 11: + case 10: return token === 23 || token === 21 || isIdentifierOrPattern(); - case 16: - return isIdentifier(); - case 12: - case 14: - return token === 23 || token === 21 || isStartOfExpression(); case 15: + return isIdentifier(); + case 11: + case 13: + return token === 23 || token === 21 || isStartOfExpression(); + case 14: return isStartOfParameter(); + case 16: case 17: - case 18: return token === 23 || isStartOfType(); - case 19: + case 18: return isHeritageClause(); - case 20: + case 19: return isIdentifierOrKeyword(); + case 20: case 21: - case 22: - case 24: - return JSDocParser.isJSDocType(); case 23: + return JSDocParser.isJSDocType(); + case 22: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -5838,41 +5956,40 @@ var ts; switch (kind) { case 1: case 2: - case 3: + case 4: case 5: case 6: - case 7: - case 13: - case 10: - case 20: - return token === 15; - case 4: - return token === 15 || token === 67 || token === 73; - case 8: - return token === 14 || token === 79 || token === 102; - case 9: - return isVariableDeclaratorListTerminator(); - case 16: - return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; case 12: - return token === 17 || token === 22; - case 14: - case 18: - case 11: - return token === 19; - case 15: - return token === 17 || token === 19; - case 17: - return token === 25 || token === 16; + case 9: case 19: + return token === 15; + case 3: + return token === 15 || token === 67 || token === 73; + case 7: + return token === 14 || token === 79 || token === 102; + case 8: + return isVariableDeclaratorListTerminator(); + case 15: + return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; + case 11: + return token === 17 || token === 22; + case 13: + case 17: + case 10: + return token === 19; + case 14: + return token === 17 || token === 19; + case 16: + return token === 25 || token === 16; + case 18: return token === 14 || token === 15; - case 21: + case 20: return token === 17 || token === 51 || token === 15; - case 22: + case 21: return token === 25 || token === 15; - case 24: - return token === 19 || token === 15; case 23: + return token === 19 || token === 15; + case 22: return token === 15; } } @@ -5889,7 +6006,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 25; kind++) { + for (var kind = 0; kind < 24; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -5898,43 +6015,25 @@ var ts; } return false; } - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -5959,7 +6058,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 63; + var nodeContextFlags = node.parserContextFlags & 62; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -5975,61 +6074,47 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1: - return isReusableModuleElement(node); - case 6: - return isReusableClassMember(node); - case 3: - return isReusableSwitchClause(node); - case 2: - case 4: - return isReusableStatement(node); - case 7: - return isReusableEnumMember(node); case 5: + return isReusableClassMember(node); + case 2: + return isReusableSwitchClause(node); + case 0: + case 1: + case 3: + return isReusableStatement(node); + case 6: + return isReusableEnumMember(node); + case 4: return isReusableTypeMember(node); - case 9: - return isReusableVariableDeclaration(node); - case 15: - return isReusableParameter(node); - case 19: - case 16: - case 18: - case 17: - case 12: - case 13: case 8: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210: - case 209: - case 216: - case 215: - case 202: - case 203: - case 206: - case 205: - return true; - } - return isReusableStatement(node); + return isReusableVariableDeclaration(node); + case 14: + return isReusableParameter(node); + case 18: + case 15: + case 17: + case 16: + case 11: + case 12: + case 7: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136: - case 141: - case 135: case 137: + case 142: case 138: - case 133: - case 179: + case 139: + case 134: + case 181: return true; + case 136: + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 && + methodDeclaration.name.originalKeywordKind === 114; + return !nameIsConstructor; } } return false; @@ -6037,8 +6122,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221: - case 222: + case 223: + case 224: return true; } } @@ -6047,56 +6132,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201: - case 181: - case 180: - case 184: + case 203: case 183: - case 196: - case 192: - case 194: - case 191: - case 190: - case 188: - case 189: - case 187: - case 186: - case 193: case 182: - case 197: - case 195: + case 186: case 185: case 198: + case 194: + case 196: + case 193: + case 192: + case 190: + case 191: + case 189: + case 188: + case 195: + case 184: + case 199: + case 197: + case 187: + case 200: + case 212: + case 211: + case 218: + case 217: + case 208: + case 204: + case 205: + case 207: + case 206: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227; + return node.kind === 229; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140: - case 134: case 141: - case 132: - case 139: + case 135: + case 142: + case 133: + case 140: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199) { + if (node.kind !== 201) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130) { + if (node.kind !== 131) { return false; } var parameter = node; @@ -6114,29 +6208,28 @@ var ts; switch (context) { case 0: return ts.Diagnostics.Declaration_or_statement_expected; case 1: return ts.Diagnostics.Declaration_or_statement_expected; - case 2: return ts.Diagnostics.Statement_expected; - case 3: return ts.Diagnostics.case_or_default_expected; - case 4: return ts.Diagnostics.Statement_expected; - case 5: return ts.Diagnostics.Property_or_signature_expected; - case 6: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7: return ts.Diagnostics.Enum_member_expected; - case 8: return ts.Diagnostics.Expression_expected; - case 9: return ts.Diagnostics.Variable_declaration_expected; - case 10: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12: return ts.Diagnostics.Argument_expression_expected; - case 13: return ts.Diagnostics.Property_assignment_expected; - case 14: return ts.Diagnostics.Expression_or_comma_expected; - case 15: return ts.Diagnostics.Parameter_declaration_expected; - case 16: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_argument_expected; - case 18: return ts.Diagnostics.Type_expected; - case 19: return ts.Diagnostics.Unexpected_token_expected; - case 20: return ts.Diagnostics.Identifier_expected; - case 21: return ts.Diagnostics.Parameter_declaration_expected; - case 22: return ts.Diagnostics.Type_argument_expected; - case 24: return ts.Diagnostics.Type_expected; - case 23: return ts.Diagnostics.Property_assignment_expected; + case 2: return ts.Diagnostics.case_or_default_expected; + case 3: return ts.Diagnostics.Statement_expected; + case 4: return ts.Diagnostics.Property_or_signature_expected; + case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6: return ts.Diagnostics.Enum_member_expected; + case 7: return ts.Diagnostics.Expression_expected; + case 8: return ts.Diagnostics.Variable_declaration_expected; + case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11: return ts.Diagnostics.Argument_expression_expected; + case 12: return ts.Diagnostics.Property_assignment_expected; + case 13: return ts.Diagnostics.Expression_or_comma_expected; + case 14: return ts.Diagnostics.Parameter_declaration_expected; + case 15: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16: return ts.Diagnostics.Type_argument_expected; + case 17: return ts.Diagnostics.Type_expected; + case 18: return ts.Diagnostics.Unexpected_token_expected; + case 19: return ts.Diagnostics.Identifier_expected; + case 20: return ts.Diagnostics.Parameter_declaration_expected; + case 21: return ts.Diagnostics.Type_argument_expected; + case 23: return ts.Diagnostics.Type_expected; + case 22: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -6195,7 +6288,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(127, entity.pos); + var node = createNode(128, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6203,7 +6296,7 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); @@ -6212,7 +6305,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172); + var template = createNode(174); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -6225,7 +6318,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178); + var span = createNode(180); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -6258,22 +6351,30 @@ var ts; } return node; } - function parseTypeReference() { - var node = createNode(142); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 && token === 117 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145); + var node = createNode(147); parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129); + var node = createNode(130); node.name = parseIdentifier(); if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6287,7 +6388,7 @@ var ts; } function parseTypeParameters() { if (token === 24) { - return parseBracketedList(16, parseTypeParameter, 24, 25); + return parseBracketedList(15, parseTypeParameter, 24, 25); } } function parseParameterType() { @@ -6308,7 +6409,7 @@ var ts; } } function parseParameter() { - var node = createNode(130); + var node = createNode(131); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); @@ -6342,7 +6443,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15, parseParameter); + var result = parseDelimitedList(14, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17) && requireCompleteParameterList) { @@ -6360,7 +6461,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140) { + if (kind === 141) { parseExpected(88); } fillSignature(51, false, false, node); @@ -6400,10 +6501,10 @@ var ts; return token === 51 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141, fullStart); + var node = createNode(142, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15, parseParameter, 18, 19); + node.parameters = parseBracketedList(14, parseParameter, 18, 19); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6413,7 +6514,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(134, fullStart); + var method = createNode(135, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -6421,7 +6522,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132, fullStart); + var property = createNode(133, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6463,14 +6564,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(139); + return parseSignatureMember(140); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140); + return parseSignatureMember(141); } case 8: case 7: @@ -6500,14 +6601,14 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(146); + var node = createNode(148); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14)) { - members = parseList(5, false, parseTypeMember); + members = parseList(4, parseTypeMember); parseExpected(15); } else { @@ -6516,12 +6617,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148); - node.elementTypes = parseBracketedList(18, parseType, 18, 19); + var node = createNode(150); + node.elementTypes = parseBracketedList(17, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150); + var node = createNode(152); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6529,7 +6630,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144) { + if (kind === 146) { parseExpected(88); } fillSignature(32, false, false, node); @@ -6542,12 +6643,12 @@ var ts; function parseNonArrayType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99: return parseTokenNode(); case 97: @@ -6559,16 +6660,16 @@ var ts; case 16: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 97: case 14: @@ -6590,7 +6691,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(147, type.pos); + var node = createNode(149, type.pos); node.elementType = type; type = finishNode(node); } @@ -6605,7 +6706,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149, type.pos); + var node = createNode(151, type.pos); node.types = types; type = finishNode(node); } @@ -6650,10 +6751,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143); + return parseFunctionOrConstructorType(145); } if (token === 88) { - return parseFunctionOrConstructorType(144); + return parseFunctionOrConstructorType(146); } return parseUnionTypeOrHigher(); } @@ -6774,10 +6875,7 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -6786,7 +6884,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6800,8 +6898,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164, identifier.pos); - var parameter = createNode(130, identifier.pos); + var node = createNode(166, identifier.pos); + var parameter = createNode(131, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -6879,7 +6977,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164); + var node = createNode(166); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6907,7 +7005,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(171, leftOperand.pos); + var node = createNode(173, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -6920,7 +7018,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 126; + return t === 86 || t === 127; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6981,33 +7079,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170, left.pos); + var node = createNode(172, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168); + var node = createNode(170); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165); + var node = createNode(167); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166); + var node = createNode(168); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167); + var node = createNode(169); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7037,7 +7135,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169, expression.pos); + var node = createNode(171, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7060,14 +7158,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(156, expression.pos); + var node = createNode(158, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161); + var node = createNode(163); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -7078,7 +7176,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(156, expression.pos); + var propertyAccess = createNode(158, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7086,7 +7184,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(157, expression.pos); + var indexedAccess = createNode(159, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7100,7 +7198,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(160, expression.pos); + var tagExpression = createNode(162, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -7119,7 +7217,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7127,7 +7225,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7138,7 +7236,7 @@ var ts; } function parseArgumentList() { parseExpected(16); - var result = parseDelimitedList(12, parseArgumentExpression); + var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); return result; } @@ -7146,7 +7244,7 @@ var ts; if (!parseOptional(24)) { return undefined; } - var typeArguments = parseDelimitedList(17, parseType); + var typeArguments = parseDelimitedList(16, parseType); if (!parseExpected(25)) { return undefined; } @@ -7217,42 +7315,42 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174); + var node = createNode(176); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(176) : + token === 23 ? createNode(178) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154); + var node = createNode(156); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; - node.elements = parseDelimitedList(14, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13, parseArgumentOrArrayLiteralElement); parseExpected(19); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116)) { - return parseAccessorDeclaration(137, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(121)) { return parseAccessorDeclaration(138, fullStart, decorators, modifiers); } + else if (parseContextualModifier(122)) { + return parseAccessorDeclaration(139, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7272,13 +7370,13 @@ var ts; return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226, fullStart); + var shorthandDeclaration = createNode(228, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225, fullStart); + var propertyAssignment = createNode(227, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -7287,12 +7385,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155); + var node = createNode(157); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; } - node.properties = parseDelimitedList(13, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(15); return finishNode(node); } @@ -7301,7 +7399,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163); + var node = createNode(165); parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -7316,7 +7414,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -7325,10 +7423,10 @@ var ts; } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2, checkForStrictMode, parseStatement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -7343,7 +7441,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -7351,12 +7449,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182); + var node = createNode(184); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(184); + var node = createNode(186); parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7366,7 +7464,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185); + var node = createNode(187); parseExpected(75); node.statement = parseStatement(); parseExpected(100); @@ -7377,7 +7475,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186); + var node = createNode(188); parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7400,21 +7498,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86)) { - var forInStatement = createNode(188, pos); + var forInStatement = createNode(190, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126)) { - var forOfStatement = createNode(189, pos); + else if (parseOptional(127)) { + var forOfStatement = createNode(191, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187, pos); + var forStatement = createNode(189, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7432,7 +7530,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 ? 66 : 71); + parseExpected(kind === 193 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7440,7 +7538,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -7449,7 +7547,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193); + var node = createNode(195); parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7458,32 +7556,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221); + var node = createNode(223); parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222); + var node = createNode(224); parseExpected(73); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194); + var node = createNode(196); parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(208, scanner.getStartPos()); + var caseBlock = createNode(210, scanner.getStartPos()); parseExpected(14); - caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(15); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -7491,35 +7589,35 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(196); + var node = createNode(198); parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(197); + var node = createNode(199); parseExpected(96); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 ? parseCatchClause() : undefined; if (!node.catchClause || token === 81) { parseExpected(81); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224); + var result = createNode(226); parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198); + var node = createNode(200); parseExpected(72); parseSemicolon(); return finishNode(node); @@ -7528,13 +7626,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(195, fullStart); + var labeledStatement = createNode(197, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183, fullStart); + var expressionStatement = createNode(185, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -7547,7 +7645,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98: @@ -7556,28 +7658,30 @@ var ts; case 83: case 69: case 77: - return 1; + return true; case 103: - case 124: - nextToken(); - return isIdentifierOrKeyword() ? 1 : 0; - case 117: + case 125: + return nextTokenIsIdentifierOnSameLine(); case 118: + case 119: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115: nextToken(); - return isIdentifierOrKeyword() || token === 8 ? 2 : 0; + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85: nextToken(); return token === 8 || token === 35 || - token === 14 || isIdentifierOrKeyword() ? - 2 : 0; + token === 14 || isIdentifierOrKeyword(); case 78: nextToken(); if (token === 53 || token === 35 || token === 14 || token === 73) { - return 2; + return true; } continue; - case 115: case 108: case 106: case 107: @@ -7585,14 +7689,14 @@ var ts; nextToken(); continue; default: - return 0; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52: case 22: @@ -7616,56 +7720,39 @@ var ts; case 72: case 68: case 81: - return 1; + return true; case 70: case 78: case 85: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115: case 103: - case 117: case 118: - case 124: - return getDeclarationFlags() || 1; + case 119: + case 125: + return true; case 108: case 106: case 107: case 109: - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 : 1); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 : 0; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 || token === 18); + return isIdentifier() || token === 14 || token === 18; } function isLetDeclaration() { - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1); - } - function parseModuleElement() { - return parseModuleElementOfKind(3); - } - function parseSourceElement() { - return parseModuleElementOfKind(3); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22: return parseEmptyStatement(); case 14: - return parseBlock(false, false); + return parseBlock(false); case 98: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104: @@ -7686,9 +7773,9 @@ var ts; case 82: return parseForOrForInOrForOfStatement(); case 71: - return parseBreakOrContinueStatement(190); + return parseBreakOrContinueStatement(192); case 66: - return parseBreakOrContinueStatement(191); + return parseBreakOrContinueStatement(193); case 90: return parseReturnStatement(); case 101: @@ -7705,20 +7792,20 @@ var ts; return parseDebuggerStatement(); case 52: return parseDeclaration(); - case 70: + case 103: + case 125: + case 118: + case 119: case 115: + case 70: case 77: case 78: case 85: - case 103: - case 117: - case 118: case 106: case 107: case 108: case 109: - case 124: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -7740,12 +7827,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124: + case 125: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117: case 118: + case 119: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -7755,8 +7842,8 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { - var node = createMissingNode(219, true, ts.Diagnostics.Declaration_expected); + if (decorators || modifiers) { + var node = createMissingNode(221, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -7764,6 +7851,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 && canParseSemicolon()) { parseSemicolon(); @@ -7773,16 +7864,16 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(176); + return createNode(178); } - var node = createNode(153); + var node = createNode(155); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153); + var node = createNode(155); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 51) { @@ -7797,16 +7888,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151); + var node = createNode(153); parseExpected(14); - node.elements = parseDelimitedList(10, parseObjectBindingElement); + node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152); + var node = createNode(154); parseExpected(18); - node.elements = parseDelimitedList(11, parseArrayBindingElement); + node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(19); return finishNode(node); } @@ -7823,7 +7914,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199); + var node = createNode(201); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7832,7 +7923,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200); + var node = createNode(202); switch (token) { case 98: break; @@ -7846,13 +7937,13 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 126 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9, parseVariableDeclaration); + node.declarations = parseDelimitedList(8, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -7861,7 +7952,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181, fullStart); + var node = createNode(183, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7869,7 +7960,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(203, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83); @@ -7880,7 +7971,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136, pos); + var node = createNode(137, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114); @@ -7889,7 +7980,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135, fullStart); + var method = createNode(136, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -7900,7 +7991,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133, fullStart); + var property = createNode(134, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -7969,7 +8060,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 121 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 122 || idToken === 116) { return true; } switch (token) { @@ -7996,7 +8087,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131, decoratorStart); + var decorator = createNode(132, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8029,7 +8120,7 @@ var ts; } function parseClassElement() { if (token === 22) { - var result = createNode(179); + var result = createNode(181); nextToken(); return finishNode(result); } @@ -8053,21 +8144,19 @@ var ts; token === 18) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { var name_6 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 175); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 177); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -8084,9 +8173,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -8100,23 +8187,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19, false, parseHeritageClause); + return parseList(18, parseHeritageClause); } function parseHeritageClause() { if (token === 79 || token === 102) { - var node = createNode(223); + var node = createNode(225); node.token = token; nextToken(); - node.types = parseDelimitedList(8, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177); + var node = createNode(179); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } @@ -8124,10 +8211,10 @@ var ts; return token === 79 || token === 102; } function parseClassMembers() { - return parseList(6, false, parseClassElement); + return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103); @@ -8138,30 +8225,31 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124); + parseExpected(125); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(229, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { - node.members = parseDelimitedList(7, parseEnumMember); + node.members = parseDelimitedList(6, parseEnumMember); parseExpected(15); } else { @@ -8170,9 +8258,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207, scanner.getStartPos()); + var node = createNode(209, scanner.getStartPos()); if (parseExpected(14)) { - node.statements = parseList(1, false, parseModuleElement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -8181,7 +8269,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -8192,7 +8280,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8201,11 +8289,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118)) { + if (parseOptional(119)) { flags |= 32768; } else { - parseExpected(117); + parseExpected(118); if (token === 8) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8213,7 +8301,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 && + return token === 120 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -8222,7 +8310,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 125; + token === 126; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85); @@ -8230,8 +8318,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 125) { - var importEqualsDeclaration = createNode(209, fullStart); + if (token !== 23 && token !== 126) { + var importEqualsDeclaration = createNode(211, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -8241,14 +8329,14 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(210, fullStart); + var importDeclaration = createNode(212, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125); + parseExpected(126); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -8261,13 +8349,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211, fullStart); + var importClause = createNode(213, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(213); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(215); } return finishNode(importClause); } @@ -8277,8 +8365,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220); - parseExpected(119); + var node = createNode(222); + parseExpected(120); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -8292,7 +8380,7 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(212); + var namespaceImport = createNode(214); parseExpected(35); parseExpected(111); namespaceImport.name = parseIdentifier(); @@ -8300,14 +8388,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 213 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(19, kind === 215 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218); + return parseImportOrExportSpecifier(220); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214); + return parseImportOrExportSpecifier(216); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8326,22 +8414,22 @@ var ts; else { node.name = identifierName; } - if (kind === 214 && checkIdentifierIsKeyword) { + if (kind === 216 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(125); + parseExpected(126); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217); - if (parseOptional(125)) { + node.exportClause = parseNamedImportsOrExports(219); + if (parseOptional(126)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8349,7 +8437,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53)) { @@ -8414,15 +8502,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 209 && node.moduleReference.kind === 220 - || node.kind === 210 - || node.kind === 215 - || node.kind === 216 + || node.kind === 211 && node.moduleReference.kind === 222 + || node.kind === 212 + || node.kind === 217 + || node.kind === 218 ? node : undefined; }); @@ -8457,7 +8545,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(229); + var result = createNode(231); parseExpected(14); result.type = parseJSDocTopLevelType(); parseExpected(15); @@ -8468,12 +8556,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44) { - var unionType = createNode(233, type.pos); + var unionType = createNode(235, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53) { - var optionalType = createNode(240, type.pos); + var optionalType = createNode(242, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -8484,20 +8572,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18) { - var arrayType = createNode(232, type.pos); + var arrayType = createNode(234, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19); type = finishNode(arrayType); } else if (token === 50) { - var nullableType = createNode(235, type.pos); + var nullableType = createNode(237, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46) { - var nonNullableType = createNode(236, type.pos); + var nonNullableType = createNode(238, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -8531,40 +8619,40 @@ var ts; case 93: return parseJSDocThisType(); case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244); + var result = createNode(246); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243); + var result = createNode(245); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242); + var result = createNode(244); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241); + var result = createNode(243); nextToken(); parseExpected(16); - result.parameters = parseDelimitedList(21, parseJSDocParameter); + result.parameters = parseDelimitedList(20, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17); if (token === 51) { @@ -8574,18 +8662,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130); + var parameter = createNode(131); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240, type.pos); + var result = createNode(242, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239); + var result = createNode(241); result.name = parseSimplePropertyName(); while (parseOptional(20)) { if (token === 24) { @@ -8600,7 +8688,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(22, parseJSDocType); + var typeArguments = parseDelimitedList(21, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25); @@ -8614,21 +8702,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127, left.pos); + var result = createNode(128, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237); + var result = createNode(239); nextToken(); - result.members = parseDelimitedList(23, parseJSDocRecordMember); + result.members = parseDelimitedList(22, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238); + var result = createNode(240); result.name = parseSimplePropertyName(); if (token === 51) { nextToken(); @@ -8637,15 +8725,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236); + var result = createNode(238); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234); + var result = createNode(236); nextToken(); - result.types = parseDelimitedList(24, parseJSDocType); + result.types = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19); return finishNode(result); @@ -8657,7 +8745,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233); + var result = createNode(235); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17); @@ -8675,7 +8763,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230); + var result = createNode(232); nextToken(); return finishNode(result); } @@ -8688,11 +8776,11 @@ var ts; token === 25 || token === 53 || token === 44) { - var result = createNode(231, pos); + var result = createNode(233, pos); return finishNode(result); } else { - var result = createNode(235, pos); + var result = createNode(237, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -8763,7 +8851,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245, start); + var result = createNode(247, start); result.tags = tags; return finishNode(result, end); } @@ -8801,7 +8889,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246, atToken.pos); + var result = createNode(248, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -8853,7 +8941,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247, atToken.pos); + var result = createNode(249, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -8863,27 +8951,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248, atToken.pos); + var result = createNode(250, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249, atToken.pos); + var result = createNode(251, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -8896,7 +8984,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129, name_7.pos); + var typeParameter = createNode(130, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -8907,7 +8995,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250, atToken.pos); + var result = createNode(252, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9222,16 +9310,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 203 || node.kind === 204) { + if (node.kind === 205 || node.kind === 206) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 210 || node.kind === 209) && !(node.flags & 1)) { + else if ((node.kind === 212 || node.kind === 211) && !(node.flags & 1)) { return 0; } - else if (node.kind === 207) { + else if (node.kind === 209) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9247,7 +9335,7 @@ var ts; }); return state; } - else if (node.kind === 206) { + else if (node.kind === 208) { return getModuleInstanceState(node.body); } else { @@ -9266,11 +9354,14 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -9296,10 +9387,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 && node.name.kind === 8) { + if (node.kind === 208 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128) { + if (node.name.kind === 129) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -9307,22 +9398,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136: + case 137: return "__constructor"; - case 143: - case 139: - return "__call"; - case 144: + case 145: case 140: - return "__new"; + return "__call"; + case 146: case 141: + return "__new"; + case 142: return "__index"; - case 216: + case 218: return "__export"; - case 215: + case 217: return node.isExportEquals ? "export=" : "default"; - case 201: - case 202: + case 203: + case 204: return node.flags & 256 ? "default" : undefined; } } @@ -9337,6 +9428,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0, name)); + if (name && (includes & 788448)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -9361,7 +9455,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 218 || (node.kind === 209 && hasExportModifier)) { + if (node.kind === 220 || (node.kind === 211 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -9407,36 +9501,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175: - case 202: - case 203: + case 177: + case 204: case 205: - case 146: - case 155: + case 207: + case 148: + case 157: return 1; - case 139: case 140: case 141: - case 135: - case 134: - case 201: + case 142: case 136: + case 135: + case 203: case 137: case 138: - case 143: - case 144: - case 163: - case 164: - case 206: - case 228: - return 5; - case 224: - case 187: - case 188: - case 189: + case 139: + case 145: + case 146: + case 165: + case 166: case 208: + case 230: + case 206: + return 5; + case 226: + case 189: + case 190: + case 191: + case 210: return 2; - case 180: + case 182: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -9452,32 +9547,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 206: + case 208: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228: + case 230: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175: - case 202: + case 177: + case 204: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205: + case 207: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146: - case 155: - case 203: + case 148: + case 157: + case 205: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: - case 135: - case 134: + case 142: case 136: + case 135: case 137: case 138: - case 201: - case 163: - case 164: + case 139: + case 203: + case 165: + case 166: + case 206: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -9501,11 +9597,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 ? node : node.body; - if (body.kind === 228 || body.kind === 207) { + var body = node.kind === 230 ? node : node.body; + if (body.kind === 230 || body.kind === 209) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 || stat.kind === 215) { + if (stat.kind === 218 || stat.kind === 217) { return true; } } @@ -9550,16 +9646,41 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65) { + continue; + } + var identifier = prop.name; + var currentKind = prop.kind === 227 || prop.kind === 228 || prop.kind === 136 + ? 1 + : 2; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 && existingKind === 1) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206: + case 208: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228: + case 230: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -9575,79 +9696,223 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2, 107455); } + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 && + node.originalKeywordKind <= 110 && + !ts.isIdentifierName(node)) { + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + if (inStrictMode && node.expression.kind === 65) { + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + if (inStrictMode) { + if (node.operator === 38 || node.operator === 39) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } bindWorker(node); bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230: + case 209: + updateStrictModeStatementList(node.statements); + return; + case 182: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204: + case 177: + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 130: - return bindParameter(node); - case 199: - case 153: - return bindVariableDeclarationOrBindingElement(node); - case 133: - case 132: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 225: + case 65: + return checkStrictModeIdentifier(node); + case 172: + return checkStrictModeBinaryExpression(node); case 226: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); + return checkStrictModeCatchClause(node); + case 167: + return checkStrictModeDeleteExpression(node); + case 7: + return checkStrictModeNumericLiteral(node); + case 171: + return checkStrictModePostfixUnaryExpression(node); + case 170: + return checkStrictModePrefixUnaryExpression(node); + case 195: + return checkStrictModeWithStatement(node); + case 130: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 131: + return bindParameter(node); + case 201: + case 155: + return bindVariableDeclarationOrBindingElement(node); + case 134: + case 133: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 227: + case 228: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 229: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 139: case 140: case 141: + case 142: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 135: - case 134: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 201: - return declareSymbolAndAddToSymbolTable(node, 16, 106927); case 136: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 137: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 138: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 143: - case 144: - return bindFunctionOrConstructorType(node); - case 146: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 155: - return bindAnonymousDeclaration(node, 4096, "__object"); - case 163: - case 164: - return bindAnonymousDeclaration(node, 16, "__function"); - case 175: - case 202: - return bindClassLikeDeclaration(node); + case 135: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); case 203: - return bindBlockScopedDeclaration(node, 64, 792992); + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 137: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 138: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 139: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 145: + case 146: + return bindFunctionOrConstructorType(node); + case 148: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 157: + return bindObjectLiteralExpression(node); + case 165: + case 166: + checkStrictModeFunctionName(node); + return bindAnonymousDeclaration(node, 16, "__function"); + case 177: case 204: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindClassLikeDeclaration(node); case 205: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 792992); case 206: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 207: + return bindEnumDeclaration(node); + case 208: return bindModuleDeclaration(node); - case 209: - case 212: - case 214: - case 218: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 211: - return bindImportClause(node); + case 214: case 216: + case 220: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 213: + return bindImportClause(node); + case 218: return bindExportDeclaration(node); - case 215: + case 217: return bindExportAssignment(node); - case 228: + case 230: return bindSourceFileIfExternalModule(); } } @@ -9658,7 +9923,10 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); + } + else if (node.expression.kind === 65) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -9666,7 +9934,10 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + } + else if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } } @@ -9676,7 +9947,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202) { + if (node.kind === 204) { bindBlockScopedDeclaration(node, 32, 899583); } else { @@ -9699,6 +9970,9 @@ var ts; : bindBlockScopedDeclaration(node, 256, 899327); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -9712,6 +9986,9 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); } @@ -9719,8 +9996,8 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 136 && - (node.parent.parent.kind === 202 || node.parent.parent.kind === 175)) { + node.parent.kind === 137 && + ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -9817,8 +10094,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -9834,10 +10111,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -9869,6 +10143,11 @@ var ts; flags: 2097152 } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { getDiagnostics(sourceFile); return emitResolver; @@ -10008,10 +10287,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228); + return ts.getAncestor(node, 230); } function isGlobalSourceFile(node) { - return node.kind === 228 && !ts.isExternalModule(node); + return node.kind === 230 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10059,34 +10338,37 @@ var ts; } } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) break; - case 206: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 218)) { - break loop; + case 208: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 || + (location.kind === 208 && location.name.kind === 8)) { + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 && + ts.getDeclarationOfKind(moduleExports[name], 220)) { + break; } - result = undefined; - } - else if (location.kind === 228 || - (location.kind === 206 && location.name.kind === 8)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931)) { + break loop; + } break; - case 205: + case 207: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 134: case 133: - case 132: - if (location.parent.kind === 202 && !(location.flags & 128)) { + if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -10095,8 +10377,9 @@ var ts; } } break; - case 202: - case 203: + case 204: + case 177: + case 205: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10104,29 +10387,36 @@ var ts; } break loop; } + if (location.kind === 177 && meaning & 32) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } break; - case 128: + case 129: grandparent = location.parent.parent; - if (grandparent.kind === 202 || grandparent.kind === 203) { + if (ts.isClassLike(grandparent) || grandparent.kind === 205) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 201: - case 164: + case 139: + case 203: + case 166: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163: + case 165: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10139,17 +10429,8 @@ var ts; } } break; - case 175: - if (meaning & 32) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - case 131: - if (location.parent && location.parent.kind === 130) { + case 132: + if (location.parent && location.parent.kind === 131) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10187,14 +10468,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 199); + var variableDeclaration = ts.getAncestor(declaration, 201); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 || - variableDeclaration.parent.parent.kind === 187) { + if (variableDeclaration.parent.parent.kind === 183 || + variableDeclaration.parent.parent.kind === 189) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 || - variableDeclaration.parent.parent.kind === 188) { + else if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 190) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10216,10 +10497,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } - while (node && node.kind !== 210) { + while (node && node.kind !== 212) { node = node.parent; } return node; @@ -10229,7 +10510,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220) { + if (node.moduleReference.kind === 222) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10318,17 +10599,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209: - return getTargetOfImportEqualsDeclaration(node); case 211: + return getTargetOfImportEqualsDeclaration(node); + case 213: return getTargetOfImportClause(node); - case 212: - return getTargetOfNamespaceImport(node); case 214: + return getTargetOfNamespaceImport(node); + case 216: return getTargetOfImportSpecifier(node); - case 218: + case 220: return getTargetOfExportSpecifier(node); - case 215: + case 217: return getTargetOfExportAssignment(node); } } @@ -10370,10 +10651,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215) { + if (node.kind === 217) { checkExpressionCached(node.expression); } - else if (node.kind === 218) { + else if (node.kind === 220) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10383,17 +10664,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209); + importDeclaration = ts.getAncestor(entityName, 211); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 127) { + if (entityName.kind === 65 || entityName.parent.kind === 128) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 209); + ts.Debug.assert(entityName.parent.kind === 211); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10412,9 +10693,9 @@ var ts; return undefined; } } - else if (name.kind === 127 || name.kind === 156) { - var left = name.kind === 127 ? name.left : name.expression; - var right = name.kind === 127 ? name.right : name.name; + else if (name.kind === 128 || name.kind === 158) { + var left = name.kind === 128 ? name.left : name.expression; + var right = name.kind === 128 ? name.right : name.name; var namespace = resolveEntityName(left, 1536); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10559,7 +10840,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10624,17 +10905,17 @@ var ts; } } switch (location_1.kind) { - case 228: + case 230: if (!ts.isExternalModule(location_1)) { break; } - case 206: + case 208: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202: - case 203: + case 204: + case 205: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -10749,8 +11030,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 && declaration.name.kind === 8) || - (declaration.kind === 228 && ts.isExternalModule(declaration)); + return (declaration.kind === 208 && declaration.name.kind === 8) || + (declaration.kind === 230 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10782,11 +11063,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 145) { + if (entityName.parent.kind === 147) { meaning = 107455 | 1048576; } - else if (entityName.kind === 127 || entityName.kind === 156 || - entityName.parent.kind === 209) { + else if (entityName.kind === 128 || entityName.kind === 158 || + entityName.parent.kind === 211) { meaning = 1536; } else { @@ -10816,6 +11097,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -10830,10 +11118,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent; } - if (node.kind === 204) { + if (node.kind === 206) { return getSymbolOfNode(node); } } @@ -10841,15 +11129,24 @@ var ts; } var _displayBuilder; function getSymbolDisplayBuilder() { - function appendSymbolNameOnly(symbol, writer) { - if (symbol.declarations && symbol.declarations.length > 0) { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; if (declaration.name) { - writer.writeSymbol(ts.declarationNameToString(declaration.name), symbol); - return; + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 177: + return "(Anonymous class)"; + case 165: + case 166: + return "(Anonymous function)"; } } - writer.writeSymbol(symbol.name, symbol); + return symbol.name; + } + function appendSymbolNameOnly(symbol, writer) { + writer.writeSymbol(getNameOfSymbol(symbol), symbol); } function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { var parentSymbol; @@ -11040,7 +11337,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 || declaration.parent.kind === 207; + return declaration.parent.kind === 230 || declaration.parent.kind === 209; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11114,7 +11411,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 123); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -11127,7 +11424,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -11170,7 +11467,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -11272,12 +11569,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206) { + if (node.kind === 208) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 228) { + else if (node.kind === 230) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11320,58 +11617,58 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153: + case 155: return isDeclarationVisible(node.parent.parent); - case 199: + case 201: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 206: - case 202: - case 203: + case 208: case 204: - case 201: case 205: - case 209: + case 206: + case 203: + case 207: + case 211: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 209 && parent_4.kind !== 228 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 && parent_4.kind !== 230 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 133: - case 132: - case 137: - case 138: - case 135: case 134: + case 133: + case 138: + case 139: + case 136: + case 135: if (node.flags & (32 | 64)) { return false; } - case 136: - case 140: - case 139: + case 137: case 141: - case 130: - case 207: - case 143: - case 144: - case 146: + case 140: case 142: - case 147: + case 131: + case 209: + case 145: + case 146: case 148: + case 144: case 149: case 150: + case 151: + case 152: return isDeclarationVisible(node.parent); - case 211: - case 212: + case 213: case 214: + case 216: return false; - case 129: - case 228: + case 130: + case 230: return true; - case 215: + case 217: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11387,10 +11684,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215) { + if (node.parent && node.parent.kind === 217) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 220) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -11436,7 +11733,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 199 ? node.parent.parent.parent : node.parent; + return node.kind === 201 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11462,7 +11759,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var name_9 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_9.text) || isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1) || @@ -11499,10 +11796,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 188) { + if (declaration.parent.parent.kind === 190) { return anyType; } - if (declaration.parent.parent.kind === 189) { + if (declaration.parent.parent.kind === 191) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11511,10 +11808,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var func = declaration.parent; - if (func.kind === 138 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137); + if (func.kind === 139 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11527,7 +11824,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 226) { + if (declaration.kind === 228) { return checkIdentifier(declaration.name); } return undefined; @@ -11556,7 +11853,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11571,7 +11868,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 + return pattern.kind === 153 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11581,7 +11878,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 225 ? getWidenedType(type) : type; + return declaration.kind !== 227 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -11589,7 +11886,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -11602,10 +11899,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224) { + if (declaration.parent.kind === 226) { return links.type = anyType; } - if (declaration.kind === 215) { + if (declaration.kind === 217) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol)) { @@ -11633,7 +11930,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137) { + if (accessor.kind === 138) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -11649,8 +11946,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137); - var setter = ts.getDeclarationOfKind(symbol, 138); + var getter = ts.getDeclarationOfKind(symbol, 138); + var setter = ts.getDeclarationOfKind(symbol, 139); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11676,7 +11973,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137); + var getter_1 = ts.getDeclarationOfKind(symbol, 138); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -11765,9 +12062,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 || node.kind === 201 || - node.kind === 163 || node.kind === 135 || - node.kind === 164) { + if (node.kind === 204 || node.kind === 177 || + node.kind === 203 || node.kind === 165 || + node.kind === 136 || node.kind === 166) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -11776,14 +12073,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 ? 202 : 203; - return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205); + return appendOuterTypeParameters(undefined, declaration); } - function getLocalTypeParametersOfClassOrInterface(symbol) { + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 || node.kind === 202) { + if (node.kind === 205 || node.kind === 204 || + node.kind === 177 || node.kind === 206) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -11793,56 +12091,109 @@ var ts; return result; } function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 && getSignaturesOfType(type, 1).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128) { + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 | 2048))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 | 2048)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); @@ -11862,7 +12213,7 @@ var ts; var kind = symbol.flags & 32 ? 1024 : 2048; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -11882,9 +12233,16 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204); + var declaration = ts.getDeclarationOfKind(symbol, 206); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -11906,7 +12264,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12021,34 +12379,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -12147,10 +12513,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -12356,7 +12722,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12378,22 +12744,31 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { - if (declaration.kind === 137 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138); + if (declaration.kind === 138 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -12404,19 +12779,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143: - case 144: - case 201: - case 135: - case 134: + case 145: + case 146: + case 203: case 136: - case 139: + case 135: + case 137: case 140: case 141: - case 137: + case 142: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12486,7 +12861,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 || signature.declaration.kind === 140; + var isConstructor = signature.declaration.kind === 137 || signature.declaration.kind === 141; var type = createObjectType(32768 | 131072); type.members = emptySymbols; type.properties = emptyArray; @@ -12500,7 +12875,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 120 : 122; + var syntaxKind = kind === 1 ? 121 : 123; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -12530,13 +12905,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130).parent); } function getTypeListId(types) { switch (types.length) { @@ -12583,18 +12958,18 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 && n.typeName.kind === 65) { + if (n.kind === 144 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); if (symbol && (symbol.flags & 262144)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -12608,55 +12983,71 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - if (node.kind !== 177 || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056); - if (symbol) { - if ((symbol.flags & 262144) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 | 2048) && type.flags & 4096) { - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), expectedTypeArgCount); - return undefined; - } - } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var typeNameOrExpression = node.kind === 144 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -12666,9 +13057,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202: - case 203: + case 204: case 205: + case 207: return declaration; } } @@ -12703,6 +13094,12 @@ var ts; function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } function createTypeFromGenericGlobalType(genericGlobalType, elementType) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; } @@ -12869,38 +13266,40 @@ var ts; switch (node.kind) { case 112: return anyType; - case 122: + case 123: return stringType; - case 120: + case 121: return numberType; case 113: return booleanType; - case 123: + case 124: return esSymbolType; case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 142: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145: - return getTypeFromTypeQueryNode(node); - case 147: - return getTypeFromArrayTypeNode(node); - case 148: - return getTypeFromTupleTypeNode(node); - case 149: - return getTypeFromUnionTypeNode(node); - case 150: - return getTypeFromTypeNode(node.type); - case 143: case 144: + return getTypeFromTypeReference(node); + case 143: + return booleanType; + case 179: + return getTypeFromTypeReference(node); + case 147: + return getTypeFromTypeQueryNode(node); + case 149: + return getTypeFromArrayTypeNode(node); + case 150: + return getTypeFromTupleTypeNode(node); + case 151: + return getTypeFromUnionTypeNode(node); + case 152: + return getTypeFromTypeNode(node.type); + case 145: case 146: + case 148: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 65: - case 127: + case 128: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -12990,11 +13389,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -13051,27 +13458,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163: - case 164: + case 165: + case 166: return isContextSensitiveFunctionLikeDeclaration(node); - case 155: + case 157: return ts.forEach(node.properties, isContextSensitive); - case 154: + case 156: return ts.forEach(node.elements, isContextSensitive); - case 171: + case 173: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170: + case 172: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225: + case 227: return isContextSensitive(node.initializer); + case 136: case 135: - case 134: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 164: return isContextSensitive(node.expression); } return false; @@ -13079,23 +13486,20 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } } return type; } - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -13111,8 +13515,8 @@ var ts; function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source, target, errorNode, headMessage) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); @@ -13346,9 +13750,9 @@ var ts; maybeStack[depth][id] = 1; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -13381,21 +13785,6 @@ var ts; } return result; } - function isDeeplyNestedGeneric(type, stack) { - if (type.flags & (4096 | 65536) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 | 65536) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -13566,6 +13955,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -13655,6 +14071,21 @@ var ts; return 0; } } + function isDeeplyNestedGeneric(type, stack, depth) { + if (type.flags & (4096 | 65536) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 | 65536) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0; } @@ -13845,22 +14276,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 134: case 133: - case 132: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130: + case 131: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201: + case 203: + case 136: case 135: - case 134: - case 137: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -13932,20 +14363,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -14003,22 +14420,26 @@ var ts; } else if (source.flags & 48128 && (target.flags & (4096 | 8192) || (target.flags & 32768) && target.symbol && target.symbol.flags & (8192 | 2048))) { - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; } } function inferFromProperties(source, target) { @@ -14043,7 +14464,14 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -14103,10 +14531,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 145: + case 147: return true; case 65: - case 127: + case 128: node = node.parent; continue; default: @@ -14148,7 +14576,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 162) { + while (n.kind === 164) { n = n.expression; } if (n.kind === 65 && getResolvedSymbol(n) === symbol) { @@ -14165,46 +14593,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170: + case 172: return isAssignedInBinaryExpression(node); - case 199: - case 153: - return isAssignedInVariableDeclaration(node); - case 151: - case 152: - case 154: + case 201: case 155: + return isAssignedInVariableDeclaration(node); + case 153: + case 154: case 156: case 157: case 158: case 159: + case 160: case 161: - case 162: - case 168: - case 165: - case 166: + case 163: + case 164: + case 170: case 167: + case 168: case 169: case 171: - case 174: - case 180: - case 181: + case 173: + case 176: + case 182: case 183: - case 184: case 185: case 186: case 187: case 188: case 189: - case 192: - case 193: + case 190: + case 191: case 194: - case 221: - case 222: case 195: case 196: - case 197: + case 223: case 224: + case 197: + case 198: + case 199: + case 226: return ts.forEachChild(node, isAssignedIn); } return false; @@ -14241,17 +14669,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184: + case 186: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171: + case 173: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170: + case 172: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -14261,14 +14689,14 @@ var ts; } } break; - case 228: - case 206: - case 201: - case 135: - case 134: - case 137: - case 138: + case 230: + case 208: + case 203: case 136: + case 135: + case 138: + case 139: + case 137: break loop; } if (narrowedType !== type) { @@ -14282,7 +14710,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 166 || expr.right.kind !== 8) { + if (expr.left.kind !== 168 || expr.right.kind !== 8) { return type; } var left = expr.left; @@ -14361,20 +14789,44 @@ var ts; } } if (targetType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + if (originalType.flags & 16384) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162: + case 160: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164: return narrowType(type, expr.expression, assumeTrue); - case 170: + case 172: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -14389,7 +14841,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168: + case 170: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -14400,7 +14852,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 && languageVersion < 2) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 && languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -14424,15 +14876,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 224) { + symbol.valueDeclaration.parent.kind === 226) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 200) { + while (container.kind !== 202) { container = container.parent; } container = container.parent; - if (container.kind === 181) { + if (container.kind === 183) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -14449,9 +14901,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 133 || container.kind === 136) { + if (container.kind === 134 || container.kind === 137) { + var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } else { @@ -14461,61 +14913,58 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 164) { + if (container.kind === 166) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 206: + case 208: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 205: + case 207: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 136: + case 137: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 134: case 133: - case 132: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128: + case 129: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; - if (classNode) { - var symbol = getSymbolOfNode(classNode); + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130) { + if (n.kind === 131) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -14523,31 +14972,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 136; + canUseSuperExpression = container.kind === 137; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 164) { + while (container && container.kind === 166) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } - if (container && container.parent && container.parent.kind === 202) { + if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || - container.kind === 138; + container.kind === 136 || + container.kind === 135 || + container.kind === 138 || + container.kind === 139; } else { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || + container.kind === 136 || + container.kind === 135 || container.kind === 138 || + container.kind === 139 || + container.kind === 134 || container.kind === 133 || - container.kind === 132 || - container.kind === 136; + container.kind === 137; } } } @@ -14555,13 +15004,13 @@ var ts; var returnType; if ((container.flags & 128) || isCallExpression) { getNodeLinks(node).flags |= 32; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -14571,7 +15020,7 @@ var ts; return returnType; } } - if (container && container.kind === 128) { + if (container && container.kind === 129) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -14609,7 +15058,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -14642,8 +15091,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 136 || - functionDecl.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138))) { + functionDecl.kind === 137 || + functionDecl.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -14662,7 +15111,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160) { + if (template.parent.kind === 162) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -14770,34 +15219,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: - case 153: + case 155: return getContextualTypeForInitializerExpression(node); - case 164: - case 192: + case 166: + case 194: return getContextualTypeForReturnExpression(node); - case 173: + case 175: return getContextualTypeForYieldOperand(parent); - case 158: - case 159: - return getContextualTypeForArgument(parent, node); + case 160: case 161: + return getContextualTypeForArgument(parent, node); + case 163: return getTypeFromTypeNode(parent.type); - case 170: + case 172: return getContextualTypeForBinaryOperand(node); - case 225: + case 227: return getContextualTypeForObjectLiteralElement(parent); - case 154: + case 156: return getContextualTypeForElementExpression(node); - case 171: + case 173: return getContextualTypeForConditionalOperand(node); - case 178: - ts.Debug.assert(parent.parent.kind === 172); + case 180: + ts.Debug.assert(parent.parent.kind === 174); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162: + case 164: return getContextualType(parent); } return undefined; @@ -14812,7 +15261,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 || node.kind === 164; + return node.kind === 165 || node.kind === 166; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -14820,7 +15269,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -14864,13 +15313,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 172 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (parent.kind === 225) { + if (parent.kind === 227) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154) { + if (parent.kind === 156) { return isAssignmentTarget(parent); } return false; @@ -14889,7 +15338,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174) { + if (inDestructuringPattern && e.kind === 176) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -14901,7 +15350,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174; + hasSpreadElement = hasSpreadElement || e.kind === 176; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -14912,7 +15361,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -14945,18 +15394,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 || - memberDecl.kind === 226 || + if (memberDecl.kind === 227 || + memberDecl.kind === 228 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225) { + if (memberDecl.kind === 227) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135) { + else if (memberDecl.kind === 136) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226); + ts.Debug.assert(memberDecl.kind === 228); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -14971,7 +15420,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 137 || memberDecl.kind === 138); + ts.Debug.assert(memberDecl.kind === 138 || memberDecl.kind === 139); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15004,7 +15453,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133; + return s.valueDeclaration ? s.valueDeclaration.kind : 134; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -15014,7 +15463,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 202); + var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -15044,7 +15493,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -15061,7 +15510,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -15071,14 +15520,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 + var left = node.kind === 158 ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { return false; } else { @@ -15093,7 +15542,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 && node.parent.expression === node) { + if (node.parent.kind === 161 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -15189,10 +15638,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160) { + if (node.kind === 162) { checkExpression(node.template); } - else { + else if (node.kind !== 132) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -15242,7 +15691,8 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174) { + var arg = args[i]; + if (arg && arg.kind === 176) { return i; } } @@ -15252,11 +15702,13 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 160) { + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 162) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172) { + if (tagExpression.template.kind === 174) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -15268,22 +15720,27 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } + else if (node.kind === 132) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + } else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 159); + ts.Debug.assert(callExpression.kind === 161); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); } var hasRightNumberOfTypeArgs = !typeArguments || (signature.typeParameters && typeArguments.length === signature.typeParameters.length); if (!hasRightNumberOfTypeArgs) { return false; } - var spreadArgIndex = getSpreadArgumentIndex(args); if (spreadArgIndex >= 0) { return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1; } @@ -15310,7 +15767,7 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument, context) { + function inferTypeArguments(node, signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; var inferenceMapper = createInferenceMapper(context); for (var i = 0; i < typeParameters.length; i++) { @@ -15321,15 +15778,13 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); - var argType = void 0; - if (i === 0 && args[i].parent.kind === 160) { - argType = globalTemplateStringsArrayType; - } - else { + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); } @@ -15337,7 +15792,7 @@ var ts; } } if (excludeArgument) { - for (var i = 0; i < args.length; i++) { + for (var i = 0; i < argCount; i++) { if (excludeArgument[i] === false) { var arg = args[i]; var paramType = getTypeAtPosition(signature, i); @@ -15347,7 +15802,7 @@ var ts; } getInferredTypes(context); } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; for (var i = 0; i < typeParameters.length; i++) { @@ -15357,23 +15812,33 @@ var ts; if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); } } } return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); - var argType = i === 0 && node.kind === 160 - ? globalTemplateStringsArrayType - : arg.kind === 8 && !reportErrors + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { + argType = arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { + } + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } } @@ -15382,35 +15847,168 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 160) { + if (node.kind === 162) { var template = node.template; - args = [template]; - if (template.kind === 172) { + args = [undefined]; + if (template.kind === 174) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } + else if (node.kind === 132) { + return undefined; + } else { args = node.arguments || emptyArray; } return args; } - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91) { - var containingClass = ts.getAncestor(callExpression, 202); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 132) { + switch (node.parent.kind) { + case 204: + case 177: + return 1; + case 134: + return 2; + case 136: + case 138: + case 139: + return signature.parameters.length >= 3 ? 3 : 2; + case 131: + return 3; + } } else { - return callExpression.typeArguments; + return args.length; } } - function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160; + function getEffectiveDecoratorFirstArgumentType(node) { + switch (node.kind) { + case 204: + case 177: + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + case 131: + node = node.parent; + if (node.kind === 137) { + var classSymbol_1 = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol_1); + } + case 134: + case 136: + case 138: + case 139: + return getParentTypeOfClassElement(node); + default: + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + } + function getEffectiveDecoratorSecondArgumentType(node) { + switch (node.kind) { + case 204: + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + case 131: + node = node.parent; + if (node.kind === 137) { + return anyType; + } + case 134: + case 136: + case 138: + case 139: + var element = node; + switch (element.name.kind) { + case 65: + case 7: + case 8: + return getStringLiteralType(element.name); + case 129: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 2097152)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } + default: + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + } + function getEffectiveDecoratorThirdArgumentType(node) { + switch (node.kind) { + case 204: + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + case 131: + return numberType; + case 134: + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + case 136: + case 138: + case 139: + 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); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + function getEffectiveArgumentType(node, argIndex, arg) { + if (node.kind === 132) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 162) { + return globalTemplateStringsArrayType; + } + return undefined; + } + function getEffectiveArgument(node, args, argIndex) { + if (node.kind === 132 || + (argIndex === 0 && node.kind === 162)) { + return undefined; + } + return args[argIndex]; + } + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 132) { + return node.expression; + } + else if (argIndex === 0 && node.kind === 162) { + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 162; + var isDecorator = node.kind === 132; var typeArguments; - if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } @@ -15418,17 +16016,19 @@ var ts; var candidates = candidatesOutArray || []; reorderCandidates(signatures, candidates); if (!candidates.length) { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); var excludeArgument; - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); + if (!isDecorator) { + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; } - excludeArgument[i] = true; } } var candidateForArgumentError; @@ -15451,19 +16051,22 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } if (!produceDiagnostics) { for (var _i = 0; _i < candidates.length; _i++) { @@ -15474,6 +16077,14 @@ var ts; } } return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } function chooseOverload(candidates, relation) { for (var _i = 0; _i < candidates.length; _i++) { var originalCandidate = candidates[_i]; @@ -15494,7 +16105,7 @@ var ts; typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } @@ -15536,7 +16147,9 @@ var ts; if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -15613,19 +16226,57 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray); } + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 204: + case 177: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 131: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 134: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 136: + case 138: + case 139: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158) { + if (node.kind === 160) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159) { + else if (node.kind === 161) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160) { + else if (node.kind === 162) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } + else if (node.kind === 132) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } else { ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); } @@ -15638,12 +16289,12 @@ var ts; if (node.expression.kind === 91) { return voidType; } - if (node.kind === 159) { + if (node.kind === 161) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 && - declaration.kind !== 140 && - declaration.kind !== 144) { + declaration.kind !== 137 && + declaration.kind !== 141 && + declaration.kind !== 146) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -15690,7 +16341,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180) { + if (func.body.kind !== 182) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -15767,7 +16418,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196); + return (body.statements.length === 1) && (body.statements[0].kind === 198); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -15776,7 +16427,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182) { return; } var bodyBlock = func.body; @@ -15789,10 +16440,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165) { + checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; @@ -15818,14 +16469,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 && node.kind !== 134) { + if (produceDiagnostics && node.kind !== 136 && node.kind !== 135) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -15833,7 +16484,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180) { + if (node.body.kind === 182) { checkSourceElement(node.body); } else { @@ -15841,7 +16492,7 @@ var ts; if (node.type) { checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); } - checkFunctionExpressionBodies(node.body); + checkFunctionAndClassExpressionBodies(node.body); } } } @@ -15863,13 +16514,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 156: { + case 158: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 157: + case 159: return true; - case 162: + case 164: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -15878,11 +16529,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65: - case 156: { + case 158: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 157: { + case 159: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { @@ -15892,7 +16543,7 @@ var ts; } return false; } - case 162: + case 164: return isConstVariableReference(n.expression); default: return false; @@ -15909,10 +16560,7 @@ var ts; return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 65) { - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -15924,9 +16572,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - if ((node.operator === 38 || node.operator === 39)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33: @@ -15949,7 +16594,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -16017,7 +16661,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 || p.kind === 226) { + if (p.kind === 227 || p.kind === 228) { var name_12 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -16042,8 +16686,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -16068,7 +16712,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 172 && restExpression.operatorToken.kind === 53) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -16081,14 +16725,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154) { + if (target.kind === 156) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -16101,11 +16745,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 155 || node.left.kind === 154)) { + if (operator === 53 && (node.left.kind === 157 || node.left.kind === 156)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -16251,7 +16892,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 || current.kind === 175) { + else if (ts.isClassLike(current)) { return true; } current = parent; @@ -16312,14 +16953,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -16341,12 +16982,8 @@ var ts; return type; } function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } - function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 127) { + if (node.kind === 128) { type = checkQualifiedName(node); } else { @@ -16354,9 +16991,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 156 && node.parent.expression === node) || - (node.parent.kind === 157 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 127) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 && node.parent.expression === node) || + (node.parent.kind === 159 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 128) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -16382,60 +17019,59 @@ var ts; return booleanType; case 7: return checkNumericLiteral(node); - case 172: + case 174: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 154: - return checkArrayLiteral(node, contextualMapper); - case 155: - return checkObjectLiteral(node, contextualMapper); case 156: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 157: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 158: + return checkPropertyAccessExpression(node); case 159: - return checkCallExpression(node); + return checkIndexedAccess(node); case 160: - return checkTaggedTemplateExpression(node); case 161: - return checkTypeAssertion(node); + return checkCallExpression(node); case 162: - return checkExpression(node.expression, contextualMapper); - case 175: - return checkClassExpression(node); + return checkTaggedTemplateExpression(node); case 163: + return checkTypeAssertion(node); case 164: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); + case 177: + return checkClassExpression(node); case 165: - return checkDeleteExpression(node); - case 167: - return checkVoidExpression(node); + case 166: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 168: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 167: + return checkDeleteExpression(node); case 169: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 170: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 171: - return checkConditionalExpression(node, contextualMapper); - case 174: - return checkSpreadElementExpression(node, contextualMapper); - case 176: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 172: + return checkBinaryExpression(node, contextualMapper); case 173: + return checkConditionalExpression(node, contextualMapper); + case 176: + return checkSpreadElementExpression(node, contextualMapper); + case 178: + return undefinedType; + case 175: return checkYieldExpression(node); } return unknownType; } function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } @@ -16450,14 +17086,12 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -16472,32 +17106,106 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 || - node.kind === 201 || - node.kind === 163; + return node.kind === 136 || + node.kind === 203 || + node.kind === 165; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166: + case 140: + case 203: + case 165: + case 145: + case 136: + case 135: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { - if (node.kind === 141) { + if (node.kind === 142) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 || node.kind === 201 || node.kind === 144 || - node.kind === 139 || node.kind === 136 || - node.kind === 140) { + else if (node.kind === 145 || node.kind === 203 || node.kind === 146 || + node.kind === 140 || node.kind === 137 || + node.kind === 141) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 || + param.name.kind === 154) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 || + element.name.kind === 153) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140: + case 141: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139: + case 140: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -16519,7 +17227,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203) { + if (node.kind === 205) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -16534,7 +17242,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122: + case 123: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -16542,7 +17250,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120: + case 121: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -16579,17 +17287,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 && n.expression.kind === 91; + return n.kind === 160 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163: - case 201: - case 164: - case 155: return false; + case 165: + case 203: + case 166: + case 157: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -16597,12 +17305,12 @@ var ts; if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 && n.kind !== 201) { + else if (n.kind !== 165 && n.kind !== 203) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 && + return n.kind === 134 && !(n.flags & 128) && !!n.initializer; } @@ -16612,7 +17320,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -16628,13 +17336,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137) { + if (node.kind === 138) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 137 ? 138 : 137; + var otherKind = node.kind === 138 ? 139 : 138; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -16656,26 +17364,26 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -16719,9 +17427,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 || signatureDeclarationNode.kind === 140); - var signatureKind = signatureDeclarationNode.kind === 139 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 || signatureDeclarationNode.kind === 141); + var signatureKind = signatureDeclarationNode.kind === 140 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -16739,7 +17447,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -16812,7 +17520,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 135 || node.kind === 134); + ts.Debug.assert(node.kind === 136 || node.kind === 135); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -16839,11 +17547,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 || node.parent.kind === 146 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 || node.parent.kind === 148 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 201 || node.kind === 135 || node.kind === 134 || node.kind === 136) { + if (node.kind === 203 || node.kind === 136 || node.kind === 135 || node.kind === 137) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -16940,16 +17648,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203: + case 205: return 2097152; - case 206: + case 208: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 202: - case 205: + case 204: + case 207: return 2097152 | 1048576; - case 209: + case 211: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -16960,57 +17668,65 @@ var ts; } } function checkDecorator(node) { - var expression = node.expression; - var exprType = checkExpression(expression); + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; switch (node.parent.kind) { - case 202: + case 204: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); - checkTypeAssignableTo(exprType, classDecoratorType, node); + expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 133: - checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); + case 131: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 135: - case 137: + case 134: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 136: case 138: + case 139: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); - checkTypeAssignableTo(exprType, methodDecoratorType, node); - break; - case 130: - checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); break; } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 142) { + if (node && node.kind === 144) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 | 132 | 258))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133: + case 134: checkTypeNodeAsExpression(node.type); break; - case 130: + case 131: checkTypeNodeAsExpression(node.type); break; - case 135: - checkTypeNodeAsExpression(node.type); - break; - case 137: + case 136: checkTypeNodeAsExpression(node.type); break; case 138: + checkTypeNodeAsExpression(node.type); + break; + case 139: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -17033,43 +17749,40 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 202: + case 204: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135: + case 136: checkParameterTypeAnnotationsAsExpressions(node); + case 139: case 138: - case 137: - case 133: - case 130: + case 134: + case 131: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130) { + if (node.kind === 131) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 128) { + if (node.name && node.name.kind === 129) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -17099,12 +17812,12 @@ var ts; } } function checkBlock(node) { - if (node.kind === 180) { + if (node.kind === 182) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207) { - checkFunctionExpressionBodies(node); + if (ts.isFunctionBlock(node) || node.kind === 209) { + checkFunctionAndClassExpressionBodies(node); } } function checkCollisionWithArgumentsInGeneratedCode(node) { @@ -17121,19 +17834,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 || - node.kind === 132 || + if (node.kind === 134 || + node.kind === 133 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || - node.kind === 138) { + node.kind === 138 || + node.kind === 139) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -17163,7 +17876,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 202); + var enclosingClass = ts.getContainingClass(node); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } @@ -17181,11 +17894,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 206 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 208 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 228 && ts.isExternalModule(parent)) { + if (parent.kind === 230 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -17196,7 +17909,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 199 && !node.initializer) { + if (node.kind === 201 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -17206,15 +17919,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200); - var container = varDeclList.parent.kind === 181 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202); + var container = varDeclList.parent.kind === 183 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 180 && ts.isFunctionLike(container.parent) || - container.kind === 207 || - container.kind === 206 || - container.kind === 228); + (container.kind === 182 && ts.isFunctionLike(container.parent) || + container.kind === 209 || + container.kind === 208 || + container.kind === 230); if (!namesShareScope) { var name_13 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); @@ -17224,7 +17937,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130) { + if (ts.getRootDeclaration(node).kind !== 131) { return; } var func = ts.getContainingFunction(node); @@ -17233,7 +17946,7 @@ var ts; if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130) { + if (referencedSymbol.valueDeclaration.kind === 131) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -17251,10 +17964,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -17263,7 +17975,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 130 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -17291,9 +18003,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 && node.kind !== 132) { + if (node.kind !== 134 && node.kind !== 133) { checkExportsOnMergedDeclarations(node); - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -17322,7 +18034,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 || node.kind === 155) { + if (node.kind === 182 || node.kind === 157) { return true; } node = node.parent; @@ -17350,12 +18062,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200) { + if (node.initializer && node.initializer.kind === 202) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -17370,13 +18082,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -17391,7 +18103,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -17401,7 +18113,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -17563,7 +18275,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138))); + return !!(node.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -17575,31 +18287,28 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { return; } - if (func.kind === 138) { + if (func.kind === 139) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136) { + else if (func.kind === 137) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -17609,7 +18318,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 222 && !hasDuplicateDefaultClause) { + if (clause.kind === 224 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -17621,7 +18330,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221) { + if (produceDiagnostics && clause.kind === 223) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -17638,7 +18347,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 && current.label.text === node.label.text) { + if (current.kind === 197 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -17682,7 +18391,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -17702,7 +18410,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 202) { + if (type.flags & 1024 && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -17733,7 +18441,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 128 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -17778,15 +18486,17 @@ var ts; } } function checkClassExpression(node) { - grammarErrorOnNode(node, ts.Diagnostics.class_expressions_are_not_currently_supported); - ts.forEach(node.members, checkSourceElement); - return unknownType; + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); if (!node.name && !(node.flags & 256)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); checkDecorators(node); if (node.name) { @@ -17801,35 +18511,38 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -17844,7 +18557,6 @@ var ts; } }); } - ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -17911,7 +18623,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 || kind === 138; + return kind === 138 || kind === 139; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -17971,13 +18683,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -17997,7 +18709,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -18018,7 +18730,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -18054,7 +18766,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168: + case 170: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -18065,7 +18777,7 @@ var ts; case 47: return ~value; } return undefined; - case 170: + case 172: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -18090,11 +18802,11 @@ var ts; return undefined; case 7: return +e.text; - case 162: + case 164: return evalConstant(e.expression); case 65: - case 157: - case 156: + case 159: + case 158: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -18105,7 +18817,7 @@ var ts; } else { var expression; - if (e.kind === 157) { + if (e.kind === 159) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -18122,7 +18834,7 @@ var ts; if (current.kind === 65) { break; } - else if (current.kind === 156) { + else if (current.kind === 158) { current = current.expression; } else { @@ -18157,7 +18869,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -18179,7 +18891,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 205) { + if (declaration.kind !== 207) { return false; } var enumDeclaration = declaration; @@ -18202,8 +18914,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 || - (declaration.kind === 201 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 || + (declaration.kind === 203 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -18225,7 +18937,14 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -18247,13 +18966,13 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 202); + var mergedClass = ts.getDeclarationOfKind(symbol, 204); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048; } } - if (node.name.kind === 8) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -18266,10 +18985,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127) { + if (node.kind === 128) { node = node.left; } - else if (node.kind === 156) { + else if (node.kind === 158) { node = node.expression; } else { @@ -18285,9 +19004,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 ? + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -18306,7 +19025,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 ? + var message = node.kind === 220 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -18319,7 +19038,10 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -18329,7 +19051,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { checkImportBinding(importClause.namedBindings); } else { @@ -18340,7 +19062,10 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -18368,14 +19093,17 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -18387,6 +19115,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 && node.parent.kind !== 209 && node.parent.kind !== 208) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -18394,8 +19127,11 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 ? node.parent : node.parent.parent; - if (container.kind === 206 && container.name.kind === 65) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + return; + } + var container = node.parent.kind === 230 ? node.parent : node.parent.parent; + if (container.kind === 208 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -18419,10 +19155,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228) { + if (node.kind === 230) { return node.statements; } - if (node.kind === 206 && node.body.kind === 207) { + if (node.kind === 208 && node.body.kind === 209) { return node.body.statements; } return emptyArray; @@ -18447,170 +19183,178 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129: - return checkTypeParameter(node); case 130: + return checkTypeParameter(node); + case 131: return checkParameter(node); + case 134: case 133: - case 132: return checkPropertyDeclaration(node); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: - return checkSignatureDeclaration(node); case 141: return checkSignatureDeclaration(node); - case 135: - case 134: - return checkMethodDeclaration(node); - case 136: - return checkConstructorDeclaration(node); - case 137: - case 138: - return checkAccessorDeclaration(node); case 142: + return checkSignatureDeclaration(node); + case 136: + case 135: + return checkMethodDeclaration(node); + case 137: + return checkConstructorDeclaration(node); + case 138: + case 139: + return checkAccessorDeclaration(node); + case 144: return checkTypeReferenceNode(node); - case 145: - return checkTypeQuery(node); - case 146: - return checkTypeLiteral(node); + case 143: + return checkTypePredicate(node); case 147: - return checkArrayType(node); + return checkTypeQuery(node); case 148: - return checkTupleType(node); + return checkTypeLiteral(node); case 149: - return checkUnionType(node); + return checkArrayType(node); case 150: + return checkTupleType(node); + case 151: + return checkUnionType(node); + case 152: return checkSourceElement(node.type); - case 201: - return checkFunctionDeclaration(node); - case 180: - case 207: - return checkBlock(node); - case 181: - return checkVariableStatement(node); - case 183: - return checkExpressionStatement(node); - case 184: - return checkIfStatement(node); - case 185: - return checkDoStatement(node); - case 186: - return checkWhileStatement(node); - case 187: - return checkForStatement(node); - case 188: - return checkForInStatement(node); - case 189: - return checkForOfStatement(node); - case 190: - case 191: - return checkBreakOrContinueStatement(node); - case 192: - return checkReturnStatement(node); - case 193: - return checkWithStatement(node); - case 194: - return checkSwitchStatement(node); - case 195: - return checkLabeledStatement(node); - case 196: - return checkThrowStatement(node); - case 197: - return checkTryStatement(node); - case 199: - return checkVariableDeclaration(node); - case 153: - return checkBindingElement(node); - case 202: - return checkClassDeclaration(node); case 203: - return checkInterfaceDeclaration(node); - case 204: - return checkTypeAliasDeclaration(node); - case 205: - return checkEnumDeclaration(node); - case 206: - return checkModuleDeclaration(node); - case 210: - return checkImportDeclaration(node); - case 209: - return checkImportEqualsDeclaration(node); - case 216: - return checkExportDeclaration(node); - case 215: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 182: - checkGrammarStatementInAmbientContext(node); - return; + case 209: + return checkBlock(node); + case 183: + return checkVariableStatement(node); + case 185: + return checkExpressionStatement(node); + case 186: + return checkIfStatement(node); + case 187: + return checkDoStatement(node); + case 188: + return checkWhileStatement(node); + case 189: + return checkForStatement(node); + case 190: + return checkForInStatement(node); + case 191: + return checkForOfStatement(node); + case 192: + case 193: + return checkBreakOrContinueStatement(node); + case 194: + return checkReturnStatement(node); + case 195: + return checkWithStatement(node); + case 196: + return checkSwitchStatement(node); + case 197: + return checkLabeledStatement(node); case 198: + return checkThrowStatement(node); + case 199: + return checkTryStatement(node); + case 201: + return checkVariableDeclaration(node); + case 155: + return checkBindingElement(node); + case 204: + return checkClassDeclaration(node); + case 205: + return checkInterfaceDeclaration(node); + case 206: + return checkTypeAliasDeclaration(node); + case 207: + return checkEnumDeclaration(node); + case 208: + return checkModuleDeclaration(node); + case 212: + return checkImportDeclaration(node); + case 211: + return checkImportEqualsDeclaration(node); + case 218: + return checkExportDeclaration(node); + case 217: + return checkExportAssignment(node); + case 184: checkGrammarStatementInAmbientContext(node); return; - case 219: + case 200: + checkGrammarStatementInAmbientContext(node); + return; + case 221: return checkMissingDeclaration(node); } } - function checkFunctionExpressionBodies(node) { + function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 163: - case 164: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 165: + case 166: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case 177: + ts.forEach(node.members, checkSourceElement); + break; + case 136: case 135: - case 134: - ts.forEach(node.decorators, checkFunctionExpressionBodies); - ts.forEach(node.parameters, checkFunctionExpressionBodies); + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136: case 137: case 138: - case 201: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 139: + case 203: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 193: - checkFunctionExpressionBodies(node.expression); + case 195: + checkFunctionAndClassExpressionBodies(node.expression); break; - case 131: - case 130: - case 133: case 132: - case 151: - case 152: + case 131: + case 134: + case 133: case 153: case 154: case 155: - case 225: case 156: case 157: + case 227: case 158: case 159: case 160: - case 172: - case 178: case 161: case 162: - case 166: - case 167: - case 165: - case 168: - case 169: - case 170: - case 171: case 174: case 180: - case 207: - case 181: + case 163: + case 164: + case 168: + case 169: + case 167: + case 170: + case 171: + case 172: + case 173: + case 176: + case 182: + case 209: case 183: - case 184: case 185: case 186: case 187: @@ -18619,22 +19363,24 @@ var ts; case 190: case 191: case 192: + case 193: case 194: - case 208: - case 221: - case 222: - case 195: case 196: - case 197: + case 210: + case 223: case 224: + case 197: + case 198: case 199: - case 200: + case 226: + case 201: case 202: - case 205: - case 227: - case 215: - case 228: - ts.forEachChild(node, checkFunctionExpressionBodies); + case 204: + case 207: + case 229: + case 217: + case 230: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } } @@ -18646,13 +19392,16 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1)) { + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } checkGrammarSourceFile(node); emitExtends = false; emitDecorate = false; emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); - checkFunctionExpressionBodies(node); + checkFunctionAndClassExpressionBodies(node); if (ts.isExternalModule(node)) { checkExternalModuleExports(node); } @@ -18693,7 +19442,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 && node.parent.statement === node) { + if (node.parent.kind === 195 && node.parent.statement === node) { return true; } node = node.parent; @@ -18715,23 +19464,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) { break; } - case 206: + case 208: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 205: + case 207: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 202: - case 203: + case 177: + if (location.name) { + copySymbol(location.symbol, meaning); + } + case 204: + case 205: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 163: + case 165: if (location.name) { copySymbol(location.symbol, meaning); } @@ -18759,78 +19512,44 @@ var ts; } } } - if (isInsideWithStatementBody(location)) { - return []; - } - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 228: - if (!ts.isExternalModule(location)) - break; - case 206: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); - break; - case 205: - copySymbols(getSymbolOfNode(location).exports, meaning & 8); - break; - case 202: - case 203: - if (!(memberFlags & 128)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056); - } - break; - case 163: - if (location.name) { - copySymbol(location.symbol, meaning); - } - break; - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 && + return name.kind === 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129: - case 202: - case 203: + case 130: case 204: case 205: + case 206: + case 207: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127) { + while (node.parent && node.parent.kind === 128) { node = node.parent; } - return node.parent && node.parent.kind === 142; + return node.parent && node.parent.kind === 144; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156) { + while (node.parent && node.parent.kind === 158) { node = node.parent; } - return node.parent && node.parent.kind === 177; + return node.parent && node.parent.kind === 179; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127) { + while (nodeOnRightSide.parent.kind === 128) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215) { + if (nodeOnRightSide.parent.kind === 217) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -18842,10 +19561,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215) { + if (entityName.parent.kind === 217) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 156) { + if (entityName.kind !== 158) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -18854,7 +19573,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 ? 793056 : 1536; + var meaning = entityName.parent.kind === 179 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -18866,14 +19585,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156) { + else if (entityName.kind === 158) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127) { + else if (entityName.kind === 128) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -18882,10 +19601,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 ? 793056 : 1536; + var meaning = entityName.parent.kind === 144 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } + if (entityName.parent.kind === 143) { + return resolveEntityName(entityName, 1); + } return undefined; } function getSymbolInfo(node) { @@ -18896,14 +19618,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 + return node.parent.kind === 217 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65: - case 156: - case 127: + case 158: + case 128: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93: case 91: @@ -18911,7 +19633,7 @@ var ts; return type.symbol; case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136) { + if (constructorDeclaration && constructorDeclaration.kind === 137) { return constructorDeclaration.parent.symbol; } return undefined; @@ -18919,12 +19641,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 || node.parent.kind === 216) && + ((node.parent.kind === 212 || node.parent.kind === 218) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 157 && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -18938,7 +19660,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 226) { + if (location && location.kind === 228) { return resolveEntityName(location.name, 107455); } return undefined; @@ -18953,6 +19675,9 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); @@ -18982,6 +19707,12 @@ var ts; } return checkExpression(expr); } + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = createSymbolTable(getPropertiesOfType(type)); @@ -19011,81 +19742,81 @@ var ts; } return [symbol]; } - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - if (languageVersion >= 2) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211) { - var defaultKeyword; - if (languageVersion === 0) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - if (languageVersion >= 2 || compilerOptions.module === 4) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 || node.kind === 205) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576) { + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944) { + return undefined; + } + symbol = exportSymbol; } - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 230) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 || n.kind === 207) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182: + case 210: + case 189: + case 190: + case 191: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209: case 211: - case 212: + case 213: case 214: - case 218: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 216: + case 220: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 218: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215: + case 217: return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -19130,7 +19861,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227) { + if (node.kind === 229) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -19141,10 +19872,9 @@ var ts; } return undefined; } - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -19153,14 +19883,14 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { var type = getTypeFromTypeNode(node); if (type.flags & 16) { return "void 0"; @@ -19182,42 +19912,42 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; } return "Object"; } - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { if (node) { switch (node.kind) { case 99: return "void 0"; - case 150: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143: - case 144: + case 152: + return serializeTypeNode(node.type); + case 145: + case 146: return "Function"; - case 147: - case 148: + case 149: + case 150: return "Array"; case 113: return "Boolean"; - case 122: + case 123: case 8: return "String"; - case 120: + case 121: return "Number"; - case 142: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145: - case 146: - case 149: + case 144: + return serializeTypeReferenceNode(node); + case 147: + case 148: + case 151: case 112: break; default: @@ -19227,23 +19957,23 @@ var ts; } return "Object"; } - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { switch (node.kind) { - case 202: return "Function"; - case 133: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204: return "Function"; + case 134: return serializeTypeNode(node.type); + case 131: return serializeTypeNode(node.type); + case 138: return serializeTypeNode(node.type); + case 139: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; } return "void 0"; } - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 202) { + if (node.kind === 204) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -19258,19 +19988,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147) { + if (parameterType.kind === 149) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -19279,9 +20009,9 @@ var ts; } return emptyArray; } - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -19303,25 +20033,24 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 | 8388608, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 || (n.parent.kind === 199 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 || (n.parent.kind === 201 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 224; + symbol.valueDeclaration.parent.kind !== 226; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -19341,7 +20070,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -19355,7 +20087,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -19384,10 +20115,7 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -19406,105 +20134,6 @@ var ts; } anyArrayType = createArrayType(anyType); } - function isReservedWordInStrictMode(node) { - return (node.parserContextFlags & 1) && - (102 <= node.originalKeywordKind && node.originalKeywordKind <= 110); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - if (ts.getAncestor(identifier, 202) || ts.getAncestor(identifier, 175)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130: - case 199: - case 201: - case 129: - case 153: - case 203: - case 204: - case 205: - return checkGrammarIdentifierInStrictMode(name); - case 202: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - if (typeName.kind === 65) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127) { - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - if (expression && expression.kind === 65) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -19515,7 +20144,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 || node.kind === 138) { + else if (node.kind === 138 || node.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -19525,33 +20154,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137: case 138: - case 136: - case 133: - case 132: - case 135: + case 139: + case 137: case 134: - case 141: - case 206: - case 210: - case 209: - case 216: - case 215: - case 130: + case 133: + case 136: + case 135: + case 142: + case 208: + case 212: + case 211: + case 218: + case 217: + case 131: break; - case 202: - case 203: - case 181: - case 201: case 204: - if (node.modifiers && node.parent.kind !== 207 && node.parent.kind !== 228) { + case 205: + case 183: + case 203: + case 206: + if (node.modifiers && node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205: + case 207: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70) && - node.parent.kind !== 207 && node.parent.kind !== 228) { + node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -19587,7 +20216,7 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -19596,10 +20225,10 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; @@ -19612,10 +20241,10 @@ var ts; else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -19624,13 +20253,13 @@ var ts; if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -19638,7 +20267,7 @@ var ts; break; } } - if (node.kind === 136) { + if (node.kind === 137) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -19649,10 +20278,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 || node.kind === 209) && flags & 2) { + else if ((node.kind === 212 || node.kind === 211) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -19715,7 +20344,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164) { + if (node.kind === 166) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -19750,7 +20379,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 && parameter.type.kind !== 120) { + if (parameter.type.kind !== 123 && parameter.type.kind !== 121) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -19782,7 +20411,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176) { + if (arg.kind === 178) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -19853,19 +20482,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 172 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 || - node.kind === 163 || - node.kind === 135); + ts.Debug.assert(node.kind === 203 || + node.kind === 165 || + node.kind === 136); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -19877,9 +20506,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -19891,55 +20517,52 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 || - name_17.kind === 128) { - checkGrammarComputedPropertyName(name_17); + var name_15 = prop.name; + if (prop.kind === 178 || + name_15.kind === 129) { + checkGrammarComputedPropertyName(name_15); continue; } var currentKind = void 0; - if (prop.kind === 225 || prop.kind === 226) { + if (prop.kind === 227 || prop.kind === 228) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135) { + else if (prop.kind === 136) { currentKind = Property; } - else if (prop.kind === 137) { + else if (prop.kind === 138) { currentKind = GetAccessor; } - else if (prop.kind === 138) { + else if (prop.kind === 139) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -19948,24 +20571,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200) { + if (forInOrOfStatement.initializer.kind === 202) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -19988,10 +20611,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 && accessor.parameters.length) { + else if (kind === 138 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138) { + else if (kind === 139) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -20016,7 +20639,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -20026,7 +20649,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155) { + if (node.parent.kind === 157) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -20034,7 +20657,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -20045,22 +20668,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 189: + case 190: + case 191: case 187: case 188: - case 189: - case 185: - case 186: return true; - case 195: + case 197: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -20072,9 +20695,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195: + case 197: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 190 + var isMisplacedContinueLabel = node.kind === 192 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -20082,8 +20705,8 @@ var ts; return false; } break; - case 194: - if (node.kind === 191 && !node.label) { + case 196: + if (node.kind === 193 && !node.label) { return false; } break; @@ -20096,13 +20719,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -20114,17 +20737,16 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 || node.name.kind === 151) { + if (node.name.kind === 154 || node.name.kind === 153) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 && node.parent.parent.kind !== 189) { + if (node.parent.parent.kind !== 190 && node.parent.parent.kind !== 191) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -20141,8 +20763,7 @@ var ts; } } var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65) { @@ -20154,7 +20775,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -20171,15 +20792,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184: - case 185: case 186: - case 193: case 187: case 188: - case 189: - return false; case 195: + case 189: + case 190: + case 191: + return false; + case 197: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -20195,7 +20816,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168) { + if (expression.kind === 170) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -20214,7 +20835,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 128) { + if (node.name.kind === 129) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -20256,23 +20877,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -20284,18 +20888,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -20305,11 +20909,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - node.kind === 216 || - node.kind === 215 || + if (node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + node.kind === 218 || + node.kind === 217 || (node.flags & 2) || (node.flags & (1 | 256))) { return false; @@ -20319,7 +20923,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181) { + if (ts.isDeclaration(decl) || decl.kind === 183) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -20338,7 +20942,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 180 || node.parent.kind === 207 || node.parent.kind === 228) { + if (node.parent.kind === 182 || node.parent.kind === 209 || node.parent.kind === 230) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -20349,13 +20953,8 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 16384) { - if (node.parserContextFlags & 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 && languageVersion >= 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -20366,8 +20965,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -20419,7 +21016,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210); + ts.Debug.assert(aliasEmitInfo.node.kind === 212); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -20492,10 +21089,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199) { + if (declaration.kind === 201) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 || declaration.kind === 214 || declaration.kind === 211) { + else if (declaration.kind === 215 || declaration.kind === 216 || declaration.kind === 213) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -20506,7 +21103,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210) { + if (moduleElementEmitInfo.node.kind === 212) { moduleElementEmitInfo.isVisible = true; } else { @@ -20514,12 +21111,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -20607,39 +21204,39 @@ var ts; function emitType(type) { switch (type.kind) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 177: + case 179: return emitExpressionWithTypeArguments(type); - case 142: - return emitTypeReference(type); - case 145: - return emitTypeQuery(type); - case 147: - return emitArrayType(type); - case 148: - return emitTupleType(type); - case 149: - return emitUnionType(type); - case 150: - return emitParenType(type); - case 143: case 144: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 147: + return emitTypeQuery(type); + case 149: + return emitArrayType(type); + case 150: + return emitTupleType(type); + case 151: + return emitUnionType(type); + case 152: + return emitParenType(type); + case 145: case 146: + return emitSignatureDeclarationWithJsDocComments(type); + case 148: return emitTypeLiteral(type); case 65: return emitEntityName(type); - case 127: + case 128: return emitEntityName(type); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 209 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 211 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -20647,8 +21244,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 ? entityName.left : entityName.expression; - var right = entityName.kind === 127 ? entityName.right : entityName.name; + var left = entityName.kind === 128 ? entityName.left : entityName.expression; + var right = entityName.kind === 128 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -20657,7 +21254,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 156); + ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 158); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -20718,9 +21315,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -20761,10 +21358,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 || - (node.parent.kind === 228 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 || + (node.parent.kind === 230 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -20773,7 +21370,7 @@ var ts; }); } else { - if (node.kind === 210) { + if (node.kind === 212) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -20791,23 +21388,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201: - return writeFunctionDeclaration(node); - case 181: - return writeVariableStatement(node); case 203: - return writeInterfaceDeclaration(node); - case 202: - return writeClassDeclaration(node); - case 204: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 183: + return writeVariableStatement(node); case 205: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 204: + return writeClassDeclaration(node); case 206: + return writeTypeAliasDeclaration(node); + case 207: + return writeEnumDeclaration(node); + case 208: return writeModuleDeclaration(node); - case 209: + case 211: return writeImportEqualsDeclaration(node); - case 210: + case 212: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -20821,7 +21418,7 @@ var ts; if (node.flags & 256) { write("default "); } - else if (node.kind !== 203) { + else if (node.kind !== 205) { write("declare "); } } @@ -20865,7 +21462,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -20891,7 +21488,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -20940,9 +21537,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207) { + while (node.body.kind !== 209) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -21003,7 +21605,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 && (node.parent.flags & 32); + return node.parent.kind === 136 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -21013,15 +21615,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - (node.parent.parent && node.parent.parent.kind === 146)) { - ts.Debug.assert(node.parent.kind === 135 || - node.parent.kind === 134 || - node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.kind === 139 || - node.parent.kind === 140); + if (node.parent.kind === 145 || + node.parent.kind === 146 || + (node.parent.parent && node.parent.parent.kind === 148)) { + ts.Debug.assert(node.parent.kind === 136 || + node.parent.kind === 135 || + node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.kind === 140 || + node.parent.kind === 141); emitType(node.constraint); } else { @@ -21031,31 +21633,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 202: + case 204: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203: + case 205: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140: + case 141: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139: + case 140: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 136: case 135: - case 134: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201: + case 203: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -21085,7 +21687,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 202) { + if (node.parent.parent.kind === 204) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -21162,16 +21764,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 199 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 133 || node.kind === 132) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 || node.kind === 133) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 || node.kind === 132) && node.parent.kind === 146) { + if ((node.kind === 134 || node.kind === 133) && node.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -21180,14 +21782,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199) { + if (node.kind === 201) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 || node.kind === 132) { + else if (node.kind === 134 || node.kind === 133) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21195,7 +21797,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21221,7 +21823,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { elements.push(element); } } @@ -21287,7 +21889,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 137 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -21300,7 +21902,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 + return accessor.kind === 138 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -21309,7 +21911,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138) { + if (accessorWithTypeAnnotation.kind === 139) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -21355,17 +21957,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201) { + if (node.kind === 203) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135) { + else if (node.kind === 136) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201) { + if (node.kind === 203) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136) { + else if (node.kind === 137) { write("constructor"); } else { @@ -21382,11 +21984,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 140 || node.kind === 144) { + if (node.kind === 141 || node.kind === 146) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141) { + if (node.kind === 142) { write("["); } else { @@ -21395,20 +21997,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141) { + if (node.kind === 142) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 143 || node.kind === 144; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146) { + var isFunctionTypeOrConstructorType = node.kind === 145 || node.kind === 146; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 && !(node.flags & 32)) { + else if (node.kind !== 137 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -21419,23 +22021,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140: + case 141: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141: + case 142: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 136: case 135: - case 134: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21443,7 +22045,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21456,7 +22058,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201: + case 203: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21488,9 +22090,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.parent.kind === 146) { + if (node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -21506,22 +22108,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136: + case 137: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140: + case 141: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139: + case 140: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 136: case 135: - case 134: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21529,7 +22131,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21541,7 +22143,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201: + case 203: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21552,12 +22154,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 151) { + if (bindingPattern.kind === 153) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152) { + else if (bindingPattern.kind === 154) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -21576,10 +22178,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176) { + if (bindingElement.kind === 178) { write(" "); } - else if (bindingElement.kind === 153) { + else if (bindingElement.kind === 155) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -21602,39 +22204,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201: - case 206: - case 209: case 203: - case 202: - case 204: + case 208: + case 211: case 205: + case 204: + case 206: + case 207: return emitModuleElement(node, isModuleElementVisible(node)); - case 181: + case 183: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210: + case 212: return emitModuleElement(node, !node.importClause); - case 216: + case 218: return emitExportDeclaration(node); + case 137: case 136: case 135: - case 134: return writeFunctionDeclaration(node); - case 140: - case 139: case 141: + case 140: + case 142: return emitSignatureDeclarationWithJsDocComments(node); - case 137: case 138: + case 139: return emitAccessorDeclaration(node); + case 134: case 133: - case 132: return emitPropertyDeclaration(node); - case 227: + case 229: return emitEnumMemberDeclaration(node); - case 215: + case 217: return emitExportAssignment(node); - case 228: + case 230: return emitSourceFile(node); } } @@ -21680,7 +22282,7 @@ var ts; } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -21744,7 +22346,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -21804,9 +22405,9 @@ var ts; var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -21824,72 +22425,43 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65) { - var name_20 = node.name.text; - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForClassExpression() { + return makeUniqueName("class"); } function generateNameForNode(node) { switch (node.kind) { - case 201: - case 202: - case 175: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205: - generateNameForModuleOrEnum(node); - break; - case 210: - generateNameForImportDeclaration(node); - break; - case 216: - generateNameForExportDeclaration(node); - break; - case 215: - generateNameForExportAssignment(node); - break; + case 65: + return makeUniqueName(node.text); + case 208: + case 207: + return generateNameForModuleOrEnum(node); + case 212: + case 218: + return generateNameForImportOrExportDeclaration(node); + case 203: + case 204: + case 217: + return generateNameForExportDefault(); + case 177: + return generateNameForClassExpression(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -21913,7 +22485,7 @@ var ts; return; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; } @@ -21966,8 +22538,8 @@ var ts; var emittedLine = writer.getLine(); var emittedColumn = writer.getColumn(); if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -22021,8 +22593,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -22039,19 +22611,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 201 || - node.kind === 163 || + else if (node.kind === 203 || + node.kind === 165 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || node.kind === 138 || - node.kind === 206 || - node.kind === 202 || - node.kind === 205) { + node.kind === 139 || + node.kind === 208 || + node.kind === 204 || + node.kind === 207) { if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 128 - ? ts.getTextOfNode(name_22) + var name_19 = node.name; + scopeName = name_19.kind === 129 + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -22144,19 +22716,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228) { + if (node.kind !== 230) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -22394,10 +22966,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 172) { + if (node.template.kind === 174) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 + var needsParens = templateSpan.expression.kind === 172 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -22421,7 +22993,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 162 + var needsParens = templateSpan.expression.kind !== 164 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -22454,11 +23026,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158: - case 159: - return parent.expression === template; case 160: + case 161: + return parent.expression === template; case 162: + case 164: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -22466,7 +23038,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 170: + case 172: switch (expression.operatorToken.kind) { case 35: case 36: @@ -22478,8 +23050,8 @@ var ts; default: return -1; } + case 175: case 173: - case 171: return -1; default: return 1; @@ -22491,11 +23063,11 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153); + ts.Debug.assert(node.kind !== 155); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 128) { + else if (node.kind === 129) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -22523,75 +23095,122 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130: - case 199: - case 153: - case 133: + case 156: + case 172: + case 160: + case 223: + case 129: + case 173: case 132: - case 225: - case 226: + case 167: + case 187: + case 159: + case 217: + case 185: + case 179: + case 189: + case 190: + case 191: + case 186: + case 161: + case 164: + case 171: + case 170: + case 194: + case 228: + case 176: + case 196: + case 162: + case 180: + case 198: + case 163: + case 168: + case 169: + case 188: + case 195: + case 175: + return true; + case 155: + case 229: + case 131: case 227: - case 135: case 134: case 201: - case 137: - case 138: - case 163: - case 202: - case 203: - case 205: - case 206: - case 209: + return parent.initializer === node; + case 158: + return parent.expression === node; + case 166: + case 165: + return parent.body === node; case 211: - case 212: - return parent.name === node; - case 214: - case 218: - return parent.name === node || parent.propertyName === node; - case 191: - case 190: - case 215: - return false; - case 195: - return node.parent.label === node; + return parent.moduleReference === node; + case 128: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230) { + if (languageVersion < 2 && compilerOptions.module !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155: + case 204: + case 207: + case 201: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -22632,7 +23251,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -22663,11 +23282,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: - case 154: case 156: - case 157: case 158: - case 162: + case 159: + case 160: + case 164: return false; } return true; @@ -22684,17 +23303,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174) { + if (e.kind === 176) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174) { + while (i < length && elements[i].kind !== 176) { i++; } write("["); @@ -22717,7 +23336,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174; + return node.kind === 176; } function emitArrayLiteral(node) { var elements = node.elements; @@ -22778,7 +23397,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 || property.kind === 138) { + if (property.kind === 138 || property.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -22829,13 +23448,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225) { + if (property.kind === 227) { emit(property.initializer); } - else if (property.kind === 226) { + else if (property.kind === 228) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135) { + else if (property.kind === 136) { emitFunctionDeclaration(property); } else { @@ -22867,7 +23486,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128) { + if (properties[i].name.kind === 129) { numInitialNonComputedProperties = i; break; } @@ -22881,35 +23500,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170, startsOnNewLine); + var result = ts.createSynthesizedNode(172, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156); + var result = ts.createSynthesizedNode(158); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157); + var result = ts.createSynthesizedNode(159); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 161) { + while (expr.kind === 163) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 && + expr.kind !== 161 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(162); + var node = ts.createSynthesizedNode(164); node.expression = expr; return node; } @@ -22922,32 +23541,26 @@ var ts; if (languageVersion >= 2 && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - if (languageVersion < 2) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - write(": "); - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -22958,7 +23571,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -22988,7 +23601,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -23006,10 +23619,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174; }); + return ts.forEach(elements, function (e) { return e.kind === 176; }); } function skipParentheses(node) { - while (node.kind === 162 || node.kind === 161) { + while (node.kind === 164 || node.kind === 163) { node = node.expression; } return node; @@ -23030,12 +23643,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156) { + if (expr.kind === 158) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157) { + else if (expr.kind === 159) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -23076,7 +23689,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 158 && node.expression.expression.kind === 91; } if (superCall && languageVersion < 2) { write(".call("); @@ -23127,20 +23740,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164) { - if (node.expression.kind === 161) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166) { + if (node.expression.kind === 163) { var operand = node.expression.expression; - while (operand.kind == 161) { + while (operand.kind === 163) { operand = operand.expression; } - if (operand.kind !== 168 && - operand.kind !== 167 && - operand.kind !== 166 && - operand.kind !== 165 && + if (operand.kind !== 170 && operand.kind !== 169 && - operand.kind !== 159 && - !(operand.kind === 158 && node.parent.kind === 159) && - !(operand.kind === 163 && node.parent.kind === 158)) { + operand.kind !== 168 && + operand.kind !== 167 && + operand.kind !== 171 && + operand.kind !== 161 && + !(operand.kind === 160 && node.parent.kind === 161) && + !(operand.kind === 165 && node.parent.kind === 160)) { emit(operand); return; } @@ -23169,7 +23782,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 || node.parent.kind === 153); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 || node.parent.kind === 155); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -23183,7 +23796,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 168) { + if (node.operand.kind === 170) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -23226,10 +23839,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228) { + if (current.kind === 230) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207) { + else if (ts.isFunctionLike(current) || current.kind === 209) { return false; } else { @@ -23239,8 +23852,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 155 || node.left.kind === 154)) { - emitDestructuring(node, node.parent.kind === 183); + (node.left.kind === 157 || node.left.kind === 156)) { + emitDestructuring(node, node.parent.kind === 185); } else { var exportChanged = node.operatorToken.kind >= 53 && @@ -23287,7 +23900,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180) { + if (node && node.kind === 182) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -23302,12 +23915,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207) { - ts.Debug.assert(node.parent.kind === 206); + if (node.kind === 209) { + ts.Debug.assert(node.parent.kind === 208); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207) { + if (node.kind === 209) { emitTempDeclarations(true); } decreaseIndent(); @@ -23316,7 +23929,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180) { + if (node.kind === 182) { write(" "); emit(node); } @@ -23328,7 +23941,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164); + emitParenthesizedIf(node.expression, node.expression.kind === 166); write(";"); } function emitIfStatement(node) { @@ -23341,7 +23954,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 184) { + if (node.elseStatement.kind === 186) { write(" "); emit(node.elseStatement); } @@ -23353,7 +23966,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { write(" "); } else { @@ -23422,7 +24035,7 @@ var ts; var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 200) { + if (node.initializer && node.initializer.kind === 202) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -23443,13 +24056,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 189) { + if (languageVersion < 2 && node.kind === 191) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -23459,7 +24072,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188) { + if (node.kind === 190) { write(" in "); } else { @@ -23527,7 +24140,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -23549,7 +24162,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 154 || node.initializer.kind === 155) { + if (node.initializer.kind === 156 || node.initializer.kind === 157) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -23558,7 +24171,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { emitLines(node.statement.statements); } else { @@ -23570,7 +24183,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 ? 66 : 71, node.pos); + emitToken(node.kind === 193 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } @@ -23615,7 +24228,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221) { + if (node.kind === 223) { write("case "); emit(node.expression); write(":"); @@ -23670,7 +24283,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206); + } while (node && node.kind !== 208); return node; } function emitContainingModuleName(node) { @@ -23695,7 +24308,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(167); + var result = ts.createSynthesizedNode(169); result.expression = zero; return result; } @@ -23764,15 +24377,15 @@ var ts; function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 199) { + if (root.kind === 201) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130) { + else if (root.kind === 131) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170) { + if (root.kind === 172) { emitAssignmentExpression(root); } else { @@ -23783,8 +24396,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 || name.parent.kind === 153); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 || name.parent.kind === 155); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -23816,14 +24428,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(170); + var equals = ts.createSynthesizedNode(172); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171); + var cond = ts.createSynthesizedNode(173); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -23837,13 +24449,15 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65) { - return createElementAccessExpression(object, propName); + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158); + var call = ts.createSynthesizedNode(160); var sliceIdentifier = ts.createSynthesizedNode(65); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -23858,8 +24472,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 || p.kind === 226) { - var propName = (p.name); + if (p.kind === 227 || p.kind === 228) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -23871,8 +24485,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -23882,14 +24496,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154) { + else if (target.kind === 156) { emitArrayLiteralAssignment(target, value); } else { @@ -23903,14 +24517,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write(")"); } } @@ -23930,11 +24544,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176) { + else if (element.kind !== 178) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -23960,14 +24574,13 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 188 && - node.parent.parent.kind !== 189) { + node.parent.parent.kind !== 190 && + node.parent.parent.kind !== 191) { initializer = createVoidZero(); } } @@ -23985,7 +24598,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176) { + if (node.kind === 178) { return; } var name = node.name; @@ -23997,48 +24610,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 && node.parent.kind !== 153)) { + if (!node.parent || (node.parent.kind !== 201 && node.parent.kind !== 155)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - if (languageVersion >= 2 || - ts.nodeIsSynthesized(node) || - node.kind !== 65 || - (node.parent.kind !== 199 && node.parent.kind !== 153)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { - return; - } - var list = ts.getAncestor(node, 200); - if (list.parent.kind === 181) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228; - var isModuleLevelBinding = list.parent.parent.kind === 207; - var isFunctionLevelBinding = list.parent.parent.kind === 180 && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 228; + node.parent.kind === 230; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -24083,12 +24663,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); + var name_20 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -24176,12 +24756,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 && languageVersion >= 2; + return node.kind === 166 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -24192,10 +24772,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163) { + if (node.kind === 165) { return !!node.name; } - if (node.kind === 201) { + if (node.kind === 203) { return !!node.name || languageVersion < 2; } } @@ -24203,7 +24783,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { @@ -24223,10 +24803,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 201 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 203 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitTrailingComments(node); } } @@ -24273,7 +24853,7 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 180) { + else if (node.body.kind === 182) { emitBlockFunctionBody(node, node.body); } else { @@ -24298,10 +24878,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 161) { + while (current.kind === 163) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155); + emitParenthesizedIf(body, current.kind === 157); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -24373,9 +24953,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183) { + if (statement && statement.kind === 185) { var expr = statement.expression; - if (expr && expr.kind === 158) { + if (expr && expr.kind === 160) { var func = expr.expression; if (func && func.kind === 91) { return statement; @@ -24406,7 +24986,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128) { + else if (memberName.kind === 129) { emitComputedPropertyName(memberName); } else { @@ -24418,7 +24998,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 134 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -24458,11 +25038,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179) { + if (member.kind === 181) { writeLine(); write(";"); } - else if (member.kind === 135 || node.kind === 134) { + else if (member.kind === 136 || node.kind === 135) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -24481,7 +25061,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 || member.kind === 138) { + else if (member.kind === 138 || member.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -24531,22 +25111,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 || node.kind === 134) && !member.body) { + if ((member.kind === 136 || node.kind === 135) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 || - member.kind === 137 || - member.kind === 138) { + else if (member.kind === 136 || + member.kind === 138 || + member.kind === 139) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 137) { + if (member.kind === 138) { write("get "); } - else if (member.kind === 138) { + else if (member.kind === 139) { write("set "); } if (member.asteriskToken) { @@ -24557,7 +25137,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179) { + else if (member.kind === 181) { writeLine(); write(";"); } @@ -24578,10 +25158,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 136 && !member.body) { + if (member.kind === 137 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 133 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 134 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -24681,7 +25261,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202) { + if (node.kind === 204) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { write("export "); @@ -24698,7 +25278,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -24765,7 +25345,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202) { + if (node.kind === 204) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -24823,11 +25403,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202) { + if (node.kind === 204) { write(";"); } emitEnd(node); - if (node.kind === 202) { + if (node.kind === 204) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -24901,13 +25481,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 135) { + if (member.kind === 136) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 133) { + if (member.kind !== 134) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24937,7 +25517,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133) { + if (member.kind !== 134) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24976,26 +25556,26 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 135: - case 137: + case 136: case 138: - case 133: + case 139: + case 134: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 135: + case 136: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 202: - case 135: - case 138: + case 204: + case 136: + case 139: return true; } return false; @@ -25004,7 +25584,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -25017,7 +25597,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -25035,7 +25615,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -25131,7 +25711,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -25165,7 +25745,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206) { + if (moduleDeclaration.body.kind === 208) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -25200,7 +25780,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207) { + if (node.body.kind === 209) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -25239,7 +25819,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -25257,16 +25837,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 && node.importClause && !!node.importClause.name; + return node.kind === 212 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -25293,7 +25873,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -25319,7 +25899,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 211 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -25331,7 +25911,7 @@ var ts; write(" = "); } else { - var isNakedImport = 210 && !node.importClause; + var isNakedImport = 212 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -25487,8 +26067,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 && - expression.kind !== 202) { + if (expression.kind !== 203 && + expression.kind !== 204) { write(";"); } emitEnd(node); @@ -25524,18 +26104,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210: + case 212: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 209: - if (node.moduleReference.kind === 220 && resolver.isReferencedAliasDeclaration(node)) { + case 211: + if (node.moduleReference.kind === 222 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 216: + case 218: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -25548,12 +26128,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215: + case 217: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -25573,13 +26153,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -25597,8 +26180,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 216 || - (importNode.kind === 210 && !importNode.importClause); + var skipNode = importNode.kind === 218 || + (importNode.kind === 212 && !importNode.importClause); if (skipNode) { continue; } @@ -25623,7 +26206,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 && externalImport.exportClause) { + if (externalImport.kind === 218 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -25652,7 +26235,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216) { + if (externalImport.kind !== 218) { continue; } var exportDecl = externalImport; @@ -25722,11 +26305,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 + var name_22 = local.kind === 65 ? local : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); + if (name_22) { + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -25737,7 +26320,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 || local.kind === 206 || local.kind === 205) { + if (local.kind === 204 || local.kind === 208 || local.kind === 207) { emitDeclarationName(local); } else { @@ -25771,21 +26354,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 201) { + if (node.kind === 203) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202) { + if (node.kind === 204) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205) { + if (node.kind === 207) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25794,7 +26377,7 @@ var ts; } return; } - if (node.kind === 206) { + if (node.kind === 208) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25803,17 +26386,17 @@ var ts; } return; } - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65) { + var name_23 = node.name; + if (name_23.kind === 65) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -25832,7 +26415,7 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 12288) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228; + ts.getEnclosingBlockScopeContainer(node).kind === 230; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); @@ -25849,10 +26432,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -25867,27 +26450,27 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210: + case 212: if (!importNode.importClause) { break; } - case 209: + case 211: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 + var defaultName = importNode.kind === 212 ? importNode.importClause.name : importNode.name; if (defaultName) { emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 && + if (importNode.kind === 212 && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { emitExportMemberAssignments(namedBindings.name); writeLine(); } @@ -25901,7 +26484,7 @@ var ts; } decreaseIndent(); break; - case 216: + case 218: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -25935,10 +26518,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 216: - case 210: - case 209: - case 201: + case 218: + case 212: + case 211: + case 203: continue; } writeLine(); @@ -25952,7 +26535,11 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -26025,8 +26612,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -26155,7 +26742,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -26166,48 +26753,47 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 203: - case 201: - case 210: - case 209: - case 204: - case 215: - return false; - case 181: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206: - return shouldEmitModuleDeclaration(node); case 205: + case 203: + case 212: + case 211: + case 206: + case 217: + return false; + case 183: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 208: + return shouldEmitModuleDeclaration(node); + case 207: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 180 && + if (node.kind !== 182 && node.parent && - node.parent.kind === 164 && + node.parent.kind === 166 && node.parent.body === node && compilerOptions.target <= 1) { return false; } return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { switch (node.kind) { case 65: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130: + return emitIdentifier(node); + case 131: return emitParameter(node); + case 136: case 135: - case 134: return emitMethod(node); - case 137: case 138: + case 139: return emitAccessor(node); case 93: return emitThis(node); @@ -26227,131 +26813,131 @@ var ts; case 12: case 13: return emitLiteral(node); - case 172: - return emitTemplateExpression(node); - case 178: - return emitTemplateSpan(node); - case 127: - return emitQualifiedName(node); - case 151: - return emitObjectBindingPattern(node); - case 152: - return emitArrayBindingPattern(node); - case 153: - return emitBindingElement(node); - case 154: - return emitArrayLiteral(node); - case 155: - return emitObjectLiteral(node); - case 225: - return emitPropertyAssignment(node); - case 226: - return emitShorthandPropertyAssignment(node); - case 128: - return emitComputedPropertyName(node); - case 156: - return emitPropertyAccess(node); - case 157: - return emitIndexedAccess(node); - case 158: - return emitCallExpression(node); - case 159: - return emitNewExpression(node); - case 160: - return emitTaggedTemplateExpression(node); - case 161: - return emit(node.expression); - case 162: - return emitParenExpression(node); - case 201: - case 163: - case 164: - return emitFunctionDeclaration(node); - case 165: - return emitDeleteExpression(node); - case 166: - return emitTypeOfExpression(node); - case 167: - return emitVoidExpression(node); - case 168: - return emitPrefixUnaryExpression(node); - case 169: - return emitPostfixUnaryExpression(node); - case 170: - return emitBinaryExpression(node); - case 171: - return emitConditionalExpression(node); case 174: - return emitSpreadElementExpression(node); - case 173: - return emitYieldExpression(node); - case 176: - return; + return emitTemplateExpression(node); case 180: - case 207: - return emitBlock(node); - case 181: - return emitVariableStatement(node); - case 182: - return write(";"); - case 183: - return emitExpressionStatement(node); - case 184: - return emitIfStatement(node); - case 185: - return emitDoStatement(node); - case 186: - return emitWhileStatement(node); - case 187: - return emitForStatement(node); - case 189: - case 188: - return emitForInOrForOfStatement(node); - case 190: - case 191: - return emitBreakOrContinueStatement(node); - case 192: - return emitReturnStatement(node); - case 193: - return emitWithStatement(node); - case 194: - return emitSwitchStatement(node); - case 221: - case 222: - return emitCaseOrDefaultClause(node); - case 195: - return emitLabelledStatement(node); - case 196: - return emitThrowStatement(node); - case 197: - return emitTryStatement(node); - case 224: - return emitCatchClause(node); - case 198: - return emitDebuggerStatement(node); - case 199: - return emitVariableDeclaration(node); - case 175: - return emitClassExpression(node); - case 202: - return emitClassDeclaration(node); - case 203: - return emitInterfaceDeclaration(node); - case 205: - return emitEnumDeclaration(node); + return emitTemplateSpan(node); + case 128: + return emitQualifiedName(node); + case 153: + return emitObjectBindingPattern(node); + case 154: + return emitArrayBindingPattern(node); + case 155: + return emitBindingElement(node); + case 156: + return emitArrayLiteral(node); + case 157: + return emitObjectLiteral(node); case 227: - return emitEnumMember(node); - case 206: - return emitModuleDeclaration(node); - case 210: - return emitImportDeclaration(node); - case 209: - return emitImportEqualsDeclaration(node); - case 216: - return emitExportDeclaration(node); - case 215: - return emitExportAssignment(node); + return emitPropertyAssignment(node); case 228: + return emitShorthandPropertyAssignment(node); + case 129: + return emitComputedPropertyName(node); + case 158: + return emitPropertyAccess(node); + case 159: + return emitIndexedAccess(node); + case 160: + return emitCallExpression(node); + case 161: + return emitNewExpression(node); + case 162: + return emitTaggedTemplateExpression(node); + case 163: + return emit(node.expression); + case 164: + return emitParenExpression(node); + case 203: + case 165: + case 166: + return emitFunctionDeclaration(node); + case 167: + return emitDeleteExpression(node); + case 168: + return emitTypeOfExpression(node); + case 169: + return emitVoidExpression(node); + case 170: + return emitPrefixUnaryExpression(node); + case 171: + return emitPostfixUnaryExpression(node); + case 172: + return emitBinaryExpression(node); + case 173: + return emitConditionalExpression(node); + case 176: + return emitSpreadElementExpression(node); + case 175: + return emitYieldExpression(node); + case 178: + return; + case 182: + case 209: + return emitBlock(node); + case 183: + return emitVariableStatement(node); + case 184: + return write(";"); + case 185: + return emitExpressionStatement(node); + case 186: + return emitIfStatement(node); + case 187: + return emitDoStatement(node); + case 188: + return emitWhileStatement(node); + case 189: + return emitForStatement(node); + case 191: + case 190: + return emitForInOrForOfStatement(node); + case 192: + case 193: + return emitBreakOrContinueStatement(node); + case 194: + return emitReturnStatement(node); + case 195: + return emitWithStatement(node); + case 196: + return emitSwitchStatement(node); + case 223: + case 224: + return emitCaseOrDefaultClause(node); + case 197: + return emitLabelledStatement(node); + case 198: + return emitThrowStatement(node); + case 199: + return emitTryStatement(node); + case 226: + return emitCatchClause(node); + case 200: + return emitDebuggerStatement(node); + case 201: + return emitVariableDeclaration(node); + case 177: + return emitClassExpression(node); + case 204: + return emitClassDeclaration(node); + case 205: + return emitInterfaceDeclaration(node); + case 207: + return emitEnumDeclaration(node); + case 229: + return emitEnumMember(node); + case 208: + return emitModuleDeclaration(node); + case 212: + return emitImportDeclaration(node); + case 211: + return emitImportEqualsDeclaration(node); + case 218: + return emitExportDeclaration(node); + case 217: + return emitExportAssignment(node); + case 230: return emitSourceFileNode(node); } } @@ -26379,7 +26965,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -26391,7 +26977,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.end !== node.parent.end) { + if (node.parent.kind === 230 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -26569,7 +27155,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -26602,16 +27188,17 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -26621,11 +27208,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -26636,6 +27224,17 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -26665,8 +27264,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -26705,16 +27303,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -26748,14 +27344,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -26769,16 +27368,16 @@ var ts; } function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -26786,15 +27385,17 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; - filesByName[canonicalAbsolutePath] = file; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -26804,7 +27405,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -26822,7 +27423,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 || node.kind === 209 || node.kind === 216) { + if (node.kind === 212 || node.kind === 211 || node.kind === 218) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -26843,7 +27444,7 @@ var ts; } } } - else if (node.kind === 206 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 208 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -27038,98 +27639,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 185) { + if (node.parent.kind === 187) { return spanInPreviousNode(node); } - if (node.parent.kind === 187) { + if (node.parent.kind === 189) { return textSpan(node); } - if (node.parent.kind === 170 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 172 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind == 164 && node.parent.body == node) { + if (node.parent.kind === 166 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 181: + case 183: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 199: - case 133: - case 132: - return spanInVariableDeclaration(node); - case 130: - return spanInParameterDeclaration(node); case 201: - case 135: case 134: - case 137: - case 138: + case 133: + return spanInVariableDeclaration(node); + case 131: + return spanInParameterDeclaration(node); + case 203: case 136: - case 163: - case 164: + case 135: + case 138: + case 139: + case 137: + case 165: + case 166: return spanInFunctionDeclaration(node); - case 180: + case 182: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 207: + case 209: return spanInBlock(node); - case 224: + case 226: return spanInBlock(node.block); - case 183: + case 185: return textSpan(node.expression); - case 192: + case 194: return textSpan(node.getChildAt(0), node.expression); + case 188: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 187: + return spanInNode(node.statement); + case 200: + return textSpan(node.getChildAt(0)); case 186: return textSpan(node, ts.findNextToken(node.expression, node)); - case 185: - return spanInNode(node.statement); - case 198: - return textSpan(node.getChildAt(0)); - case 184: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 195: - return spanInNode(node.statement); - case 191: - case 190: - return textSpan(node.getChildAt(0), node.label); - case 187: - return spanInForStatement(node); - case 188: - case 189: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 194: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 221: - case 222: - return spanInNode(node.statements[0]); case 197: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 193: + case 192: + return textSpan(node.getChildAt(0), node.label); + case 189: + return spanInForStatement(node); + case 190: + case 191: + return textSpan(node, ts.findNextToken(node.expression, node)); case 196: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 223: + case 224: + return spanInNode(node.statements[0]); + case 199: + return spanInBlock(node.tryBlock); + case 198: return textSpan(node, node.expression); - case 215: + case 217: return textSpan(node, node.expression); - case 209: + case 211: return textSpan(node, node.moduleReference); - case 210: + case 212: return textSpan(node, node.moduleSpecifier); - case 216: + case 218: return textSpan(node, node.moduleSpecifier); - case 206: + case 208: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 202: - case 205: - case 227: - case 158: - case 159: - return textSpan(node); - case 193: - return spanInNode(node.statement); - case 203: case 204: + case 207: + case 229: + case 160: + case 161: + return textSpan(node); + case 195: + return spanInNode(node.statement); + case 205: + case 206: return undefined; case 22: case 1: @@ -27156,10 +27757,10 @@ var ts; case 81: return spanInNextNode(node); default: - if (node.parent.kind === 225 && node.parent.name === node) { + if (node.parent.kind === 227 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 161 && node.parent.type === node) { + if (node.parent.kind === 163 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -27169,12 +27770,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 188 || - variableDeclaration.parent.parent.kind === 189) { + if (variableDeclaration.parent.parent.kind === 190 || + variableDeclaration.parent.parent.kind === 191) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -27220,7 +27821,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 202 && functionDeclaration.kind !== 136); + (functionDeclaration.parent.kind === 204 && functionDeclaration.kind !== 137); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -27240,23 +27841,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 206: + case 208: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 186: - case 184: case 188: - case 189: + case 186: + case 190: + case 191: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 187: + case 189: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 200) { + if (forStatement.initializer.kind === 202) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -27275,34 +27876,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 205: + case 207: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 202: + case 204: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 208: + case 210: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 207: + case 209: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 205: - case 202: + case 207: + case 204: return textSpan(node); - case 180: + case 182: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 224: + case 226: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 208: + case 210: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -27314,24 +27915,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 185) { + if (node.parent.kind === 187) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 163: - case 201: - case 164: - case 135: - case 134: - case 137: - case 138: + case 165: + case 203: + case 166: case 136: - case 186: - case 185: + case 135: + case 138: + case 139: + case 137: + case 188: case 187: + case 189: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -27339,19 +27940,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 225) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 227) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 161) { + if (node.parent.kind === 163) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 185) { + if (node.parent.kind === 187) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -27429,7 +28030,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 164; + return ts.isFunctionBlock(node) && node.parent.kind !== 166; } var depth = 0; var maxDepth = 20; @@ -27441,26 +28042,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 180: + case 182: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_7.kind === 185 || - parent_7.kind === 188 || - parent_7.kind === 189 || - parent_7.kind === 187 || - parent_7.kind === 184 || - parent_7.kind === 186 || - parent_7.kind === 193 || - parent_7.kind === 224) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 187 || + parent_8.kind === 190 || + parent_8.kind === 191 || + parent_8.kind === 189 || + parent_8.kind === 186 || + parent_8.kind === 188 || + parent_8.kind === 195 || + parent_8.kind === 226) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 197) { - var tryStatement = parent_7; + if (parent_8.kind === 199) { + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -27480,23 +28081,23 @@ var ts; }); break; } - case 207: { + case 209: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 202: - case 203: + case 204: case 205: - case 155: - case 208: { + case 207: + case 157: + case 210: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 154: + case 156: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -27522,10 +28123,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_27 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_27); + for (var name_24 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_24); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_27); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); if (!matches) { continue; } @@ -27536,14 +28137,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_27); + matches = patternMatcher.getMatches(containers, name_24); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_27, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -27580,7 +28181,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 128) { + else if (declaration.name.kind === 129) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -27597,7 +28198,7 @@ var ts; } return true; } - if (expression.kind === 156) { + if (expression.kind === 158) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -27608,7 +28209,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 128) { + if (declaration.name.kind === 129) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -27672,14 +28273,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 206: + case 208: do { current = current.parent; - } while (current.kind === 206); - case 202: + } while (current.kind === 208); + case 204: + case 207: case 205: case 203: - case 201: indent++; } current = current.parent; @@ -27690,26 +28291,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 181: + case 183: ts.forEach(node.declarationList.declarations, visit); break; - case 151: - case 152: + case 153: + case 154: ts.forEach(node.elements, visit); break; - case 216: + case 218: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210: + case 212: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { childNodes.push(importClause.namedBindings); } else { @@ -27718,20 +28319,20 @@ var ts; } } break; - case 153: - case 199: + case 155: + case 201: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 202: + case 204: + case 207: case 205: + case 208: case 203: - case 206: - case 201: - case 209: - case 214: - case 218: + case 211: + case 216: + case 220: childNodes.push(node); break; } @@ -27766,17 +28367,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 202: + case 204: + case 207: case 205: - case 203: topLevelNodes.push(node); break; - case 206: + case 208: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 201: + case 203: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -27787,9 +28388,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 201) { - if (functionDeclaration.body && functionDeclaration.body.kind === 180) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 203) { + if (functionDeclaration.body && functionDeclaration.body.kind === 182) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -27842,7 +28443,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 130: + case 131: if (ts.isBindingPattern(node.name)) { break; } @@ -27850,34 +28451,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 136: case 135: - case 134: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 137: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 138: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 141: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 227: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 139: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 140: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 133: - case 132: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 142: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 229: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 201: + case 140: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 141: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 134: + case 133: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 203: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 199: - case 153: + case 201: + case 155: var variableDeclarationNode; - var name_28; - if (node.kind === 153) { - name_28 = node.name; + var name_25; + if (node.kind === 155) { + name_25 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 199) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 201) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -27885,24 +28486,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_28 = node.name; + name_25 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); } - case 136: + case 137: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 218: - case 214: - case 209: + case 220: + case 216: case 211: - case 212: + case 213: + case 214: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -27932,17 +28533,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 228: + case 230: return createSourceFileItem(node); - case 202: + case 204: return createClassItem(node); - case 205: + case 207: return createEnumItem(node); - case 203: + case 205: return createIterfaceItem(node); - case 206: + case 208: return createModuleItem(node); - case 201: + case 203: return createFunctionItem(node); } return undefined; @@ -27952,7 +28553,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 206) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 208) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -27964,7 +28565,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 180) { + if (node.body && node.body.kind === 182) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -27985,7 +28586,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 136 && member; + return member.kind === 137 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -28006,19 +28607,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 206) { + while (node.body.kind === 208) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 228 + return node.kind === 230 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -28401,7 +29002,7 @@ var ts; var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { if (!isAllPunctuation(identifier, wordStart, i)) { @@ -28455,7 +29056,7 @@ var ts; } function transitionFromUpperToLower(identifier, word, index, wordStart) { if (word) { - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); @@ -28509,14 +29110,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 158) { + if (argumentInfo.invocation.kind !== 160) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 65 ? expression - : expression.kind === 156 + : expression.kind === 158 ? expression.name : undefined; if (!name || !name.text) { @@ -28545,7 +29146,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 158 || node.parent.kind === 159) { + if (node.parent.kind === 160 || node.parent.kind === 161) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -28576,23 +29177,23 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 160) { + else if (node.kind === 10 && node.parent.kind === 162) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 160) { + else if (node.kind === 11 && node.parent.parent.kind === 162) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172); + ts.Debug.assert(templateExpression.kind === 174); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 178 && node.parent.parent.parent.kind === 160) { + else if (node.parent.kind === 180 && node.parent.parent.parent.kind === 162) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172); + ts.Debug.assert(templateExpression.kind === 174); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -28656,7 +29257,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 172) { + if (template.kind === 174) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -28665,7 +29266,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 228; n = n.parent) { + for (var n = node; n.kind !== 230; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -28846,39 +29447,39 @@ var ts; return false; } switch (n.kind) { - case 202: - case 203: + case 204: case 205: - case 155: - case 151: - case 146: - case 180: case 207: - case 208: + case 157: + case 153: + case 148: + case 182: + case 209: + case 210: return nodeEndsWith(n, 15, sourceFile); - case 224: + case 226: return isCompletedNode(n.block, sourceFile); - case 159: + case 161: if (!n.arguments) { return true; } - case 158: - case 162: - case 150: + case 160: + case 164: + case 152: return nodeEndsWith(n, 17, sourceFile); - case 143: - case 144: + case 145: + case 146: return isCompletedNode(n.type, sourceFile); - case 136: case 137: case 138: - case 201: - case 163: - case 135: - case 134: - case 140: case 139: - case 164: + case 203: + case 165: + case 136: + case 135: + case 141: + case 140: + case 166: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -28886,61 +29487,61 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 17, sourceFile); - case 206: + case 208: return n.body && isCompletedNode(n.body, sourceFile); - case 184: + case 186: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 183: + case 185: return isCompletedNode(n.expression, sourceFile); + case 156: case 154: - case 152: - case 157: - case 128: - case 148: + case 159: + case 129: + case 150: return nodeEndsWith(n, 19, sourceFile); - case 141: + case 142: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 221: - case 222: + case 223: + case 224: return false; - case 187: - case 188: case 189: - case 186: + case 190: + case 191: + case 188: return isCompletedNode(n.statement, sourceFile); - case 185: + case 187: var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 145: + case 147: return isCompletedNode(n.exprName, sourceFile); - case 166: - case 165: + case 168: case 167: - case 173: - case 174: + case 169: + case 175: + case 176: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 160: + case 162: return isCompletedNode(n.template, sourceFile); - case 172: + case 174: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 178: + case 180: return ts.nodeIsPresent(n.literal); - case 168: - return isCompletedNode(n.operand, sourceFile); case 170: + return isCompletedNode(n.operand, sourceFile); + case 172: return isCompletedNode(n.right, sourceFile); - case 171: + case 173: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -28983,7 +29584,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 251 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 253 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -29089,7 +29690,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 228); + ts.Debug.assert(startNode !== undefined || n.kind === 230); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -29126,17 +29727,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 142 || node.kind === 158) { + if (node.kind === 144 || node.kind === 160) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 202 || node.kind === 203) { + if (ts.isFunctionLike(node) || node.kind === 204 || node.kind === 205) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 126; + return n.kind >= 0 && n.kind <= 127; } ts.isToken = isToken; function isWord(kind) { @@ -29189,7 +29790,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -29574,7 +30175,7 @@ var ts; if (this.tokensAreOnSameLine === undefined) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; }; @@ -29593,7 +30194,7 @@ var ts; FormattingContext.prototype.NodeIsOnOneLine = function (node) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { var openBrace = ts.findChildOfKind(node, 14, this.sourceFile); @@ -29708,7 +30309,7 @@ var ts; this.customContextChecks = funcs; } RuleOperationContext.prototype.IsAny = function () { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; }; RuleOperationContext.prototype.InContext = function (context) { if (this.IsAny()) { @@ -29789,12 +30390,12 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 121]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 122]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 119]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 117, 118, 106, 108, 121, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118, 120]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 118, 119, 106, 108, 122, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); @@ -29808,7 +30409,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 121, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 122, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.FromTokens([65, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -29888,37 +30489,38 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_29 in o) { - if (o[name_29] === rule) { - return name_29; + for (var name_26 in o) { + if (o[name_26] === rule) { + return name_26; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 187; + return context.contextNode.kind === 189; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 170: - case 171: + case 172: + case 173: + case 143: return true; - case 153: - case 204: - case 209: - case 199: - case 130: - case 227: + case 155: + case 206: + case 211: + case 201: + case 131: + case 229: + case 134: case 133: - case 132: return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; - case 188: + case 190: return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; - case 189: - return context.currentTokenSpan.kind === 126 || context.nextTokenSpan.kind === 126; + case 191: + return context.currentTokenSpan.kind === 127 || context.nextTokenSpan.kind === 127; } return false; }; @@ -29926,7 +30528,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 173; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -29967,85 +30569,85 @@ var ts; return true; } switch (node.kind) { - case 180: - case 208: - case 155: - case 207: + case 182: + case 210: + case 157: + case 209: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 201: + case 203: + case 136: case 135: - case 134: - case 137: case 138: case 139: - case 163: - case 136: - case 164: - case 203: + case 140: + case 165: + case 137: + case 166: + case 205: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 201 || context.contextNode.kind === 163; + return context.contextNode.kind === 203 || context.contextNode.kind === 165; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 202: - case 203: + case 204: case 205: - case 146: - case 206: + case 207: + case 148: + case 208: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 202: - case 206: - case 205: - case 180: - case 224: + case 204: + case 208: case 207: - case 194: + case 182: + case 226: + case 209: + case 196: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 184: - case 194: - case 187: - case 188: - case 189: case 186: - case 197: - case 185: - case 193: - case 224: + case 196: + case 189: + case 190: + case 191: + case 188: + case 199: + case 187: + case 195: + case 226: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 155; + return context.contextNode.kind === 157; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 158; + return context.contextNode.kind === 160; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 159; + return context.contextNode.kind === 161; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -30069,38 +30671,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 131; + return node.kind === 132; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 200 && + return context.currentTokenParent.kind === 202 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind != 2; + return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 206; + return context.contextNode.kind === 208; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 146; + return context.contextNode.kind === 148; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 && token.kind !== 25) { return false; } switch (parent.kind) { - case 142: - case 202: + case 144: + case 204: + case 205: case 203: - case 201: - case 163: - case 164: + case 165: + case 166: + case 136: case 135: - case 134: - case 139: case 140: - case 158: - case 159: + case 141: + case 160: + case 161: return true; default: return false; @@ -30111,10 +30713,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 167; + return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 169; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 173 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 175 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -30137,7 +30739,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 126 + 1; + this.mapRowLength = 127 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -30155,13 +30757,13 @@ var ts; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange != formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != formatting.Shared.TokenRange.Any; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); @@ -30213,7 +30815,7 @@ var ts; RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - ts.Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; this.rulesInsertionIndexBitmap = temp; @@ -30230,7 +30832,7 @@ var ts; }; RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { var position; - if (rule.Operation.Action == 1) { + if (rule.Operation.Action === 1) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; @@ -30304,7 +30906,7 @@ var ts; return [this.token]; }; TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue == this.token; + return tokenValue === this.token; }; return TokenSingleValueAccess; })(); @@ -30314,7 +30916,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 126; token++) { + for (var token = 0; token <= 127; token++) { result.push(token); } return result; @@ -30356,9 +30958,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(66, 126); + TokenRange.Keywords = TokenRange.FromRange(66, 127); TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 126]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 127, 117]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); @@ -30366,7 +30968,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([65, 120, 122, 113, 123, 99, 112]); + TokenRange.TypeNames = TokenRange.FromTokens([65, 121, 123, 113, 124, 99, 112]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -30544,17 +31146,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 202: - case 203: + case 204: + case 205: return ts.rangeContainsRange(parent.members, node); - case 206: + case 208: var body = parent.body; - return body && body.kind === 180 && ts.rangeContainsRange(body.statements, node); - case 228: - case 180: - case 207: + return body && body.kind === 182 && ts.rangeContainsRange(body.statements, node); + case 230: + case 182: + case 209: return ts.rangeContainsRange(parent.statements, node); - case 224: + case 226: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -30679,9 +31281,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 228 || - parent.kind === 221 || - parent.kind === 222) { + parent.kind === 230 || + parent.kind === 223 || + parent.kind === 224) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -30714,18 +31316,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 202: return 69; - case 203: return 103; - case 201: return 83; - case 205: return 205; - case 137: return 116; - case 138: return 121; - case 135: + case 204: return 69; + case 205: return 103; + case 203: return 83; + case 207: return 207; + case 138: return 116; + case 139: return 122; + case 136: if (node.asteriskToken) { return 35; } - case 133: - case 130: + case 134: + case 131: return node.name.kind; } } @@ -30832,7 +31434,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 131 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 132 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -31122,20 +31724,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 180: - case 207: + case 182: + case 209: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 137: + case 203: + case 165: case 136: - case 201: - case 163: case 135: - case 134: - case 164: + case 166: if (node.typeParameters === list) { return 24; } @@ -31143,8 +31745,8 @@ var ts; return 16; } break; - case 158: - case 159: + case 160: + case 161: if (node.typeArguments === list) { return 24; } @@ -31152,7 +31754,7 @@ var ts; return 16; } break; - case 142: + case 144: if (node.typeArguments === list) { return 24; } @@ -31244,7 +31846,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 170) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 172) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -31269,6 +31871,10 @@ var ts; if (actualIndentation !== -1) { return actualIndentation; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + options.IndentSize; + } previous = current; current = current.parent; } @@ -31306,6 +31912,10 @@ var ts; if (actualIndentation !== -1) { return actualIndentation + indentationDelta; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } } if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; @@ -31334,7 +31944,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 228 || !parentAndChildShareLine); + (parent.kind === 230 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -31358,7 +31968,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 184 && parent.elseStatement === child) { + if (parent.kind === 186 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -31370,23 +31980,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 142: + case 144: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 155: + case 157: return node.parent.properties; - case 154: + case 156: return node.parent.elements; - case 201: - case 163: - case 164: + case 203: + case 165: + case 166: + case 136: case 135: - case 134: - case 139: - case 140: { + case 140: + case 141: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -31397,8 +32007,8 @@ var ts; } break; } - case 159: - case 158: { + case 161: + case 160: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -31422,6 +32032,42 @@ var ts; return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; } } + function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { + if (node.kind === 17) { + return -1; + } + if (node.parent && (node.parent.kind === 160 || + node.parent.kind === 161) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1; + } + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1; + } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + return -1; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 160: + case 161: + case 158: + case 159: + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); var node = list[index]; @@ -31467,28 +32113,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202: - case 203: + case 204: case 205: - case 154: - case 180: case 207: - case 155: - case 146: + case 156: + case 182: + case 209: + case 157: case 148: - case 208: - case 222: - case 221: - case 162: - case 158: - case 159: - case 181: - case 199: - case 215: - case 192: - case 171: - case 152: - case 151: + case 150: + case 210: + case 224: + case 223: + case 164: + case 160: + case 161: + case 183: + case 201: + case 217: + case 194: + case 173: + case 154: + case 153: return true; } return false; @@ -31498,22 +32144,22 @@ var ts; return true; } switch (parent) { - case 185: - case 186: - case 188: - case 189: case 187: - case 184: - case 201: - case 163: - case 135: - case 134: - case 139: - case 164: + case 188: + case 190: + case 191: + case 189: + case 186: + case 203: + case 165: case 136: + case 135: + case 140: + case 166: case 137: case 138: - return child !== 180; + case 139: + return child !== 182; default: return false; } @@ -31526,8 +32172,7 @@ var ts; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// @@ -31593,7 +32238,7 @@ var ts; return this.getEnd() - this.getStart(sourceFile); }; NodeObject.prototype.getFullWidth = function () { - return this.end - this.getFullStart(); + return this.end - this.pos; }; NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { return this.getStart(sourceFile) - this.pos; @@ -31615,7 +32260,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(251, nodes.pos, nodes.end, 1024, this); + var list = createNode(253, nodes.pos, nodes.end, 1024, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -31634,7 +32279,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 127) { + if (this.kind >= 128) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -31679,7 +32324,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 127) { + if (child.kind < 128) { return child; } return child.getFirstToken(sourceFile); @@ -31689,7 +32334,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 127) { + if (child.kind < 128) { return child; } return child.getLastToken(sourceFile); @@ -31735,7 +32380,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 130) { + if (canUseParsedParamTagComments && declaration.kind === 131) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -31743,13 +32388,13 @@ var ts; } }); } - if (declaration.kind === 206 && declaration.body.kind === 206) { + if (declaration.kind === 208 && declaration.body.kind === 208) { return; } - while (declaration.kind === 206 && declaration.parent.kind === 206) { + while (declaration.kind === 208 && declaration.parent.kind === 208) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -32054,9 +32699,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 128) { + if (declaration.name.kind === 129) { var expr = declaration.name.expression; - if (expr.kind === 156) { + if (expr.kind === 158) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -32076,9 +32721,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 201: + case 203: + case 136: case 135: - case 134: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -32095,62 +32740,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 202: - case 203: case 204: case 205: case 206: - case 209: - case 218: - case 214: - case 209: - case 211: - case 212: - case 137: - case 138: - case 146: - addDeclaration(node); - case 136: - case 181: - case 200: - case 151: - case 152: case 207: + case 208: + case 211: + case 220: + case 216: + case 211: + case 213: + case 214: + case 138: + case 139: + case 148: + addDeclaration(node); + case 137: + case 183: + case 202: + case 153: + case 154: + case 209: ts.forEachChild(node, visit); break; - case 180: + case 182: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 130: + case 131: if (!(node.flags & 112)) { break; } - case 199: - case 153: + case 201: + case 155: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 227: + case 229: + case 134: case 133: - case 132: addDeclaration(node); break; - case 216: + case 218: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210: + case 212: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { addDeclaration(importClause.namedBindings); } else { @@ -32290,14 +32935,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 163) { + if (declaration.kind === 165) { return true; } - if (declaration.kind !== 199 && declaration.kind !== 201) { + if (declaration.kind !== 201 && declaration.kind !== 203) { return false; } - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 228 || parent_8.kind === 207) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + if (parent_9.kind === 230 || parent_9.kind === 209) { return false; } } @@ -32336,8 +32981,7 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.getCanonicalFileName = getCanonicalFileName; - this.fileNameToEntry = {}; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); var rootFileNames = host.getScriptFileNames(); for (var _i = 0; _i < rootFileNames.length; _i++) { var fileName = rootFileNames[_i]; @@ -32348,9 +32992,6 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.normalizeFileName = function (fileName) { - return this.getCanonicalFileName(ts.normalizeSlashes(fileName)); - }; HostCache.prototype.createEntry = function (fileName) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -32361,13 +33002,14 @@ var ts; scriptSnapshot: scriptSnapshot }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; }; HostCache.prototype.getEntry = function (fileName) { - return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); }; HostCache.prototype.contains = function (fileName) { - return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); }; HostCache.prototype.getOrCreateEntry = function (fileName) { if (this.contains(fileName)) { @@ -32376,12 +33018,10 @@ var ts; return this.createEntry(fileName); }; HostCache.prototype.getRootFileNames = function () { - var _this = this; var fileNames = []; - ts.forEachKey(this.fileNameToEntry, function (key) { - var entry = _this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); } }); return fileNames; @@ -32428,7 +33068,7 @@ var ts; sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - function transpile(input, compilerOptions, fileName, diagnostics) { + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; options.allowNonTsExtensions = true; @@ -32436,8 +33076,8 @@ var ts; options.noResolve = true; var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics); + if (moduleName) { + sourceFile.moduleName = moduleName; } var newLine = ts.getNewLineCharacter(options); var outputText; @@ -32454,9 +33094,8 @@ var ts; getNewLine: function () { return newLine; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics()); - } + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); return outputText; @@ -32503,8 +33142,14 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createDocumentRegistry() { + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + function createDocumentRegistry(useCaseSensitiveFileNames) { var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target; } @@ -32512,7 +33157,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); } return bucket; } @@ -32521,7 +33166,7 @@ var ts; var entries = ts.lookUp(buckets, name); var sourceFiles = []; for (var i in entries) { - var entry = entries[i]; + var entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -32544,15 +33189,16 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { if (entry.sourceFile.version !== version) { @@ -32567,11 +33213,11 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.remove(fileName); } } return { @@ -32623,7 +33269,7 @@ var ts; else { if (token === 65) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32632,7 +33278,7 @@ var ts; } else if (token === 53) { token = scanner.scan(); - if (token === 119) { + if (token === 120) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -32657,7 +33303,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32671,7 +33317,7 @@ var ts; token = scanner.scan(); if (token === 65) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32691,7 +33337,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32701,7 +33347,7 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32722,7 +33368,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 195 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 197 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -32731,16 +33377,16 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 && - (node.parent.kind === 191 || node.parent.kind === 190) && + (node.parent.kind === 193 || node.parent.kind === 192) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 && - node.parent.kind === 195 && + node.parent.kind === 197 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 195; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 197; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -32751,25 +33397,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 127 && node.parent.right === node; + return node.parent.kind === 128 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 156 && node.parent.name === node; + return node && node.parent && node.parent.kind === 158 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 160 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 159 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 161 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 206 && node.parent.name === node; + return node.parent.kind === 208 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 && @@ -32777,22 +33423,22 @@ var ts; } function isNameOfPropertyAssignment(node) { return (node.kind === 65 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 225 || node.parent.kind === 226) && node.parent.name === node; + (node.parent.kind === 227 || node.parent.kind === 228) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 133: - case 132: - case 225: - case 227: - case 135: case 134: - case 137: + case 133: + case 227: + case 229: + case 136: + case 135: case 138: - case 206: + case 139: + case 208: return node.parent.name === node; - case 157: + case 159: return node.parent.argumentExpression === node; } } @@ -32830,7 +33476,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 66; i <= 126; i++) { + for (var i = 66; i <= 127; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -32845,17 +33491,17 @@ var ts; return undefined; } switch (node.kind) { - case 228: + case 230: + case 136: case 135: - case 134: - case 201: - case 163: - case 137: - case 138: - case 202: case 203: + case 165: + case 138: + case 139: + case 204: case 205: - case 206: + case 207: + case 208: return node; } } @@ -32863,38 +33509,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 206: return ScriptElementKind.moduleElement; - case 202: return ScriptElementKind.classElement; - case 203: return ScriptElementKind.interfaceElement; - case 204: return ScriptElementKind.typeElement; - case 205: return ScriptElementKind.enumElement; - case 199: + case 208: return ScriptElementKind.moduleElement; + case 204: return ScriptElementKind.classElement; + case 205: return ScriptElementKind.interfaceElement; + case 206: return ScriptElementKind.typeElement; + case 207: return ScriptElementKind.enumElement; + case 201: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 201: return ScriptElementKind.functionElement; - case 137: return ScriptElementKind.memberGetAccessorElement; - case 138: return ScriptElementKind.memberSetAccessorElement; + case 203: return ScriptElementKind.functionElement; + case 138: return ScriptElementKind.memberGetAccessorElement; + case 139: return ScriptElementKind.memberSetAccessorElement; + case 136: case 135: - case 134: return ScriptElementKind.memberFunctionElement; + case 134: case 133: - case 132: return ScriptElementKind.memberVariableElement; - case 141: return ScriptElementKind.indexSignatureElement; - case 140: return ScriptElementKind.constructSignatureElement; - case 139: return ScriptElementKind.callSignatureElement; - case 136: return ScriptElementKind.constructorImplementationElement; - case 129: return ScriptElementKind.typeParameterElement; - case 227: return ScriptElementKind.variableElement; - case 130: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 209: - case 214: + case 142: return ScriptElementKind.indexSignatureElement; + case 141: return ScriptElementKind.constructSignatureElement; + case 140: return ScriptElementKind.callSignatureElement; + case 137: return ScriptElementKind.constructorImplementationElement; + case 130: return ScriptElementKind.typeParameterElement; + case 229: return ScriptElementKind.variableElement; + case 131: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 211: - case 218: - case 212: + case 216: + case 213: + case 220: + case 214: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -32916,9 +33562,7 @@ var ts; host.log(message); } } - function getCanonicalFileName(fileName) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { fileName = ts.normalizeSlashes(fileName); var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); @@ -33048,44 +33692,44 @@ var ts; return false; } switch (node.kind) { - case 209: + case 211: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 217: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 202: + case 204: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 223: + case 225: var heritageClause = node; if (heritageClause.token === 102) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 203: + case 205: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206: + case 208: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204: + case 206: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 163: - case 201: - case 164: - case 201: + case 139: + case 165: + case 203: + case 166: + case 203: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -33093,20 +33737,20 @@ var ts; return true; } break; - case 181: + case 183: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 199: + case 201: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 158: - case 159: + case 160: + case 161: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -33114,7 +33758,7 @@ var ts; return true; } break; - case 130: + case 131: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -33130,17 +33774,17 @@ var ts; return true; } break; - case 133: + case 134: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205: + case 207: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 161: + case 163: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 131: + case 132: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -33184,7 +33828,7 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { var displayName = symbol.getName(); @@ -33257,11 +33901,11 @@ var ts; } var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 156) { + if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 158) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 127) { + else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 128) { node = contextToken.parent.left; isRightOfDot = true; } @@ -33284,7 +33928,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 || node.kind === 127 || node.kind === 156) { + if (node.kind === 65 || node.kind === 128 || node.kind === 158) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -33332,11 +33976,11 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 211)) { + else if (ts.getAncestor(contextToken, 213)) { isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 210); + var importDeclaration = ts.getAncestor(contextToken, 212); ts.Debug.assert(importDeclaration !== undefined); var exports_2; if (importDeclaration.moduleSpecifier) { @@ -33381,7 +34025,7 @@ var ts; function showCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 213; + return node.parent.kind === 215; } } return false; @@ -33391,38 +34035,38 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 158 - || containingNodeKind === 136 - || containingNodeKind === 159 - || containingNodeKind === 154 - || containingNodeKind === 170 - || containingNodeKind === 143; + return containingNodeKind === 160 + || containingNodeKind === 137 + || containingNodeKind === 161 + || containingNodeKind === 156 + || containingNodeKind === 172 + || containingNodeKind === 145; case 16: - return containingNodeKind === 158 - || containingNodeKind === 136 - || containingNodeKind === 159 - || containingNodeKind === 162 - || containingNodeKind === 150; + return containingNodeKind === 160 + || containingNodeKind === 137 + || containingNodeKind === 161 + || containingNodeKind === 164 + || containingNodeKind === 152; case 18: - return containingNodeKind === 154; - case 117: + return containingNodeKind === 156; case 118: + case 119: return true; case 20: - return containingNodeKind === 206; + return containingNodeKind === 208; case 14: - return containingNodeKind === 202; + return containingNodeKind === 204; case 53: - return containingNodeKind === 199 - || containingNodeKind === 170; + return containingNodeKind === 201 + || containingNodeKind === 172; case 11: - return containingNodeKind === 172; + return containingNodeKind === 174; case 12: - return containingNodeKind === 178; + return containingNodeKind === 180; case 108: case 106: case 107: - return containingNodeKind === 133; + return containingNodeKind === 134; } switch (previousToken.getText()) { case "public": @@ -33452,12 +34096,12 @@ var ts; function getContainingObjectLiteralApplicableForCompletion(previousToken) { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var parent_9 = previousToken.parent; + var parent_10 = previousToken.parent; switch (previousToken.kind) { case 14: case 23: - if (parent_9 && parent_9.kind === 155) { - return parent_9; + if (parent_10 && parent_10.kind === 157) { + return parent_10; } break; } @@ -33466,16 +34110,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 163: - case 164: - case 201: + case 165: + case 166: + case 203: + case 136: case 135: - case 134: - case 137: case 138: case 139: case 140: case 141: + case 142: return true; } return false; @@ -33485,63 +34129,63 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 199 || - containingNodeKind === 200 || - containingNodeKind === 181 || - containingNodeKind === 205 || - isFunction(containingNodeKind) || + return containingNodeKind === 201 || containingNodeKind === 202 || - containingNodeKind === 201 || + containingNodeKind === 183 || + containingNodeKind === 207 || + isFunction(containingNodeKind) || + containingNodeKind === 204 || containingNodeKind === 203 || - containingNodeKind === 152 || - containingNodeKind === 151; + containingNodeKind === 205 || + containingNodeKind === 154 || + containingNodeKind === 153; case 20: - return containingNodeKind === 152; + return containingNodeKind === 154; case 51: - return containingNodeKind === 153; + return containingNodeKind === 155; case 18: - return containingNodeKind === 152; + return containingNodeKind === 154; case 16: - return containingNodeKind === 224 || + return containingNodeKind === 226 || isFunction(containingNodeKind); case 14: - return containingNodeKind === 205 || - containingNodeKind === 203 || - containingNodeKind === 146 || - containingNodeKind === 151; + return containingNodeKind === 207 || + containingNodeKind === 205 || + containingNodeKind === 148 || + containingNodeKind === 153; case 22: - return containingNodeKind === 132 && + return containingNodeKind === 133 && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 203 || - previousToken.parent.parent.kind === 146); + (previousToken.parent.parent.kind === 205 || + previousToken.parent.parent.kind === 148); case 24: - return containingNodeKind === 202 || - containingNodeKind === 201 || + return containingNodeKind === 204 || containingNodeKind === 203 || + containingNodeKind === 205 || isFunction(containingNodeKind); case 109: - return containingNodeKind === 133; + return containingNodeKind === 134; case 21: - return containingNodeKind === 130 || - containingNodeKind === 136 || + return containingNodeKind === 131 || + containingNodeKind === 137 || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 152); + previousToken.parent.parent.kind === 154); case 108: case 106: case 107: - return containingNodeKind === 130; + return containingNodeKind === 131; case 69: case 77: case 103: case 83: case 98: case 116: - case 121: + case 122: case 85: case 104: case 70: case 110: - case 124: + case 125: return true; } switch (previousToken.getText()) { @@ -33572,7 +34216,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 213) { + importDeclaration.importClause.namedBindings.kind === 215) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -33589,7 +34233,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 225 && m.kind !== 226) { + if (m.kind !== 227 && m.kind !== 228) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -33635,10 +34279,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_30 in nameTable) { - if (!allNames[name_30]) { - allNames[name_30] = name_30; - var displayName = getCompletionEntryDisplayName(name_30, target, true); + for (var name_27 in nameTable) { + if (!allNames[name_27]) { + allNames[name_27] = name_27; + var displayName = getCompletionEntryDisplayName(name_27, target, true); if (displayName) { var entry = { name: displayName, @@ -33814,14 +34458,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 156) { + if (location.parent && location.parent.kind === 158) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 158 || location.kind === 159) { + if (location.kind === 160 || location.kind === 161) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -33833,7 +34477,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 159 || callExpression.expression.kind === 91; + var useConstructSignatures = callExpression.kind === 161 || callExpression.expression.kind === 91; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -33881,21 +34525,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 114 && location.parent.kind === 136)) { + (location.kind === 114 && location.parent.kind === 137)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 136 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 137 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 136) { + if (functionDeclaration.kind === 137) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -33918,7 +34562,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(124)); + displayParts.push(ts.keywordPart(125)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -33938,9 +34582,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 206); + var declaration = ts.getDeclarationOfKind(symbol, 208); var isNamespace = declaration && declaration.name && declaration.name.kind === 65; - displayParts.push(ts.keywordPart(isNamespace ? 118 : 117)); + displayParts.push(ts.keywordPart(isNamespace ? 119 : 118)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -33959,13 +34603,13 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 140) { + if (signatureDeclaration.kind === 141) { displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 139 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 140 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); @@ -33974,7 +34618,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 227) { + if (declaration.kind === 229) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -33990,13 +34634,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 209) { + if (declaration.kind === 211) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(119)); + displayParts.push(ts.keywordPart(120)); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); @@ -34120,8 +34764,8 @@ var ts; if (!symbol) { switch (node.kind) { case 65: - case 156: - case 127: + case 158: + case 128: case 93: case 91: var type = typeChecker.getTypeAtLocation(node); @@ -34175,7 +34819,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 114) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 202); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 204); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -34191,8 +34835,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 136) || - (!selectConstructors && (d.kind === 201 || d.kind === 135 || d.kind === 134))) { + if ((selectConstructors && d.kind === 137) || + (!selectConstructors && (d.kind === 203 || d.kind === 136 || d.kind === 135))) { declarations.push(d); if (d.body) definition = d; @@ -34247,7 +34891,7 @@ var ts; symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 226) { + if (node.parent.kind === 228) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -34280,7 +34924,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -34371,74 +35015,74 @@ var ts; switch (node.kind) { case 84: case 76: - if (hasKind(node.parent, 184)) { + if (hasKind(node.parent, 186)) { return getIfElseOccurrences(node.parent); } break; case 90: - if (hasKind(node.parent, 192)) { + if (hasKind(node.parent, 194)) { return getReturnOccurrences(node.parent); } break; case 94: - if (hasKind(node.parent, 196)) { + if (hasKind(node.parent, 198)) { return getThrowOccurrences(node.parent); } break; case 68: - if (hasKind(parent(parent(node)), 197)) { + if (hasKind(parent(parent(node)), 199)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96: case 81: - if (hasKind(parent(node), 197)) { + if (hasKind(parent(node), 199)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92: - if (hasKind(node.parent, 194)) { + if (hasKind(node.parent, 196)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67: case 73: - if (hasKind(parent(parent(parent(node))), 194)) { + if (hasKind(parent(parent(parent(node))), 196)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66: case 71: - if (hasKind(node.parent, 191) || hasKind(node.parent, 190)) { + if (hasKind(node.parent, 193) || hasKind(node.parent, 192)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82: - if (hasKind(node.parent, 187) || - hasKind(node.parent, 188) || - hasKind(node.parent, 189)) { + if (hasKind(node.parent, 189) || + hasKind(node.parent, 190) || + hasKind(node.parent, 191)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100: case 75: - if (hasKind(node.parent, 186) || hasKind(node.parent, 185)) { + if (hasKind(node.parent, 188) || hasKind(node.parent, 187)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114: - if (hasKind(node.parent, 136)) { + if (hasKind(node.parent, 137)) { return getConstructorOccurrences(node.parent); } break; case 116: - case 121: - if (hasKind(node.parent, 137) || hasKind(node.parent, 138)) { + case 122: + if (hasKind(node.parent, 138) || hasKind(node.parent, 139)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 181)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 183)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -34450,10 +35094,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 196) { + if (node.kind === 198) { statementAccumulator.push(node); } - else if (node.kind === 197) { + else if (node.kind === 199) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -34474,17 +35118,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_10 = child.parent; - if (ts.isFunctionBlock(parent_10) || parent_10.kind === 228) { - return parent_10; + var parent_11 = child.parent; + if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230) { + return parent_11; } - if (parent_10.kind === 197) { - var tryStatement = parent_10; + if (parent_11.kind === 199) { + var tryStatement = parent_11; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_10; + child = parent_11; } return undefined; } @@ -34493,7 +35137,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 191 || node.kind === 190) { + if (node.kind === 193 || node.kind === 192) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -34507,23 +35151,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 194: - if (statement.kind === 190) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 196: + if (statement.kind === 192) { continue; } - case 187: - case 188: case 189: - case 186: - case 185: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 190: + case 191: + case 188: + case 187: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -34534,18 +35178,18 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 202 || - (declaration.kind === 130 && hasKind(container, 136)))) { + if (!(container.kind === 204 || + (declaration.kind === 131 && hasKind(container, 137)))) { return undefined; } } else if (modifier === 109) { - if (container.kind !== 202) { + if (container.kind !== 204) { return undefined; } } else if (modifier === 78 || modifier === 115) { - if (!(container.kind === 207 || container.kind === 228)) { + if (!(container.kind === 209 || container.kind === 230)) { return undefined; } } @@ -34556,18 +35200,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 207: - case 228: + case 209: + case 230: nodes = container.statements; break; - case 136: + case 137: nodes = container.parameters.concat(container.parent.members); break; - case 202: + case 204: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 136 && member; + return member.kind === 137 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -34615,13 +35259,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 137); tryPushAccessorKeyword(accessorDeclaration.symbol, 138); + tryPushAccessorKeyword(accessorDeclaration.symbol, 139); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 121); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 122); }); } } } @@ -34638,7 +35282,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { - if (loopNode.kind === 185) { + if (loopNode.kind === 187) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100)) { @@ -34659,13 +35303,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 189: + case 190: + case 191: case 187: case 188: - case 189: - case 185: - case 186: return getLoopBreakContinueOccurrences(owner); - case 194: + case 196: return getSwitchCaseDefaultOccurrences(owner); } } @@ -34715,7 +35359,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 180))) { + if (!(func && hasKind(func.body, 182))) { return undefined; } var keywords = []; @@ -34729,7 +35373,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 184) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 186) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -34740,7 +35384,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 184)) { + if (!hasKind(ifStatement.elseStatement, 186)) { break; } ifStatement = ifStatement.elseStatement; @@ -34898,16 +35542,16 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 214 || location.parent.kind === 218) && + (location.parent.kind === 216 || location.parent.kind === 220) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 214 || declaration.kind === 218; + return declaration.kind === 216 || declaration.kind === 220; }); } function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 ? d : undefined; }); var name; if (functionExpression && functionExpression.name) { name = functionExpression.name.text; @@ -34922,7 +35566,7 @@ var ts; if (isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 ? d : undefined; }); var name = functionExpression && functionExpression.name ? functionExpression.name.text : symbol.name; @@ -34940,7 +35584,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 202); + return ts.getAncestor(privateDeclaration, 204); } } if (symbol.flags & 8388608) { @@ -34961,7 +35605,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 228 && !ts.isExternalModule(container)) { + if (container.kind === 230 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -35120,13 +35764,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 133: - case 132: - case 135: case 134: + case 133: case 136: + case 135: case 137: case 138: + case 139: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -35154,32 +35798,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { + case 136: case 135: - case 134: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 134: case 133: - case 132: - case 136: case 137: case 138: + case 139: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 228: + case 230: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 201: - case 163: + case 203: + case 165: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 228) { + if (searchSpaceNode.kind === 230) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -35210,25 +35854,25 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 163: - case 201: + case 165: + case 203: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 136: case 135: - case 134: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 202: + case 204: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 228: - if (container.kind === 228 && !ts.isExternalModule(container)) { + case 230: + if (container.kind === 230 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -35263,11 +35907,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 202) { + if (declaration.kind === 204) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 203) { + else if (declaration.kind === 205) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -35317,17 +35961,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_31 = node.text; + var name_28 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_31); + var unionProperty = contextualType.getProperty(name_28); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_31); + var symbol = t.getProperty(name_28); if (symbol) { result_4.push(symbol); } @@ -35336,7 +35980,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_31); + var symbol_1 = contextualType.getProperty(name_28); if (symbol_1) { return [symbol_1]; } @@ -35381,10 +36025,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 169 || parent.kind === 168) { + if (parent.kind === 171 || parent.kind === 170) { return true; } - else if (parent.kind === 170 && parent.left === node) { + else if (parent.kind === 172 && parent.left === node) { var operator = parent.operatorToken.kind; return 53 <= operator && operator <= 64; } @@ -35417,33 +36061,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 130: - case 199: - case 153: - case 133: - case 132: - case 225: - case 226: - case 227: - case 135: + case 131: + case 201: + case 155: case 134: + case 133: + case 227: + case 228: + case 229: case 136: + case 135: case 137: case 138: - case 201: - case 163: - case 164: - case 224: - return 1; - case 129: + case 139: case 203: - case 204: - case 146: - return 2; - case 202: + case 165: + case 166: + case 226: + return 1; + case 130: case 205: - return 1 | 2; case 206: + case 148: + return 2; + case 204: + case 207: + return 1 | 2; + case 208: if (node.name.kind === 8) { return 4 | 1; } @@ -35453,14 +36097,14 @@ var ts; else { return 4; } - case 213: - case 214: - case 209: - case 210: case 215: case 216: + case 211: + case 212: + case 217: + case 218: return 1 | 2 | 4; - case 228: + case 230: return 4 | 1; } return 1 | 2 | 4; @@ -35470,7 +36114,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 142 || node.parent.kind === 177; + return node.parent.kind === 144 || + (node.parent.kind === 179 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -35478,47 +36123,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156) { - while (root.parent && root.parent.kind === 156) { + if (root.parent.kind === 158) { + while (root.parent && root.parent.kind === 158) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 && root.parent.parent.kind === 223) { + if (!isLastClause && root.parent.kind === 179 && root.parent.parent.kind === 225) { var decl = root.parent.parent.parent; - return (decl.kind === 202 && root.parent.parent.token === 102) || - (decl.kind === 203 && root.parent.parent.token === 79); + return (decl.kind === 204 && root.parent.parent.token === 102) || + (decl.kind === 205 && root.parent.parent.token === 79); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 127) { - while (root.parent && root.parent.kind === 127) { + if (root.parent.kind === 128) { + while (root.parent && root.parent.kind === 128) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 142 && !isLastClause; + return root.parent.kind === 144 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 127) { + while (node.parent.kind === 128) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 65); - if (node.parent.kind === 127 && + if (node.parent.kind === 128 && node.parent.right === node && - node.parent.parent.kind === 209) { + node.parent.parent.kind === 211) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 215) { + if (node.parent.kind === 217) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -35552,8 +36197,8 @@ var ts; return; } switch (node.kind) { - case 156: - case 127: + case 158: + case 128: case 8: case 80: case 95: @@ -35571,7 +36216,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 206 && + if (nodeForStartPos.parent.parent.kind === 208 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -35601,6 +36246,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; + var classifiableNames = program.getClassifiableNames(); processNode(sourceFile); return { spans: result, endOfLineState: 0 }; function pushClassification(start, length, type) { @@ -35610,6 +36256,9 @@ var ts; } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); + if ((flags & 788448) === 0) { + return; + } if (flags & 32) { return 11; } @@ -35636,18 +36285,22 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 206 && ts.getModuleInstanceState(declaration) == 1; + return declaration.kind === 208 && + ts.getModuleInstanceState(declaration) === 1; }); } } function processNode(node) { - if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 65 && node.getWidth() > 0) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + if (node.kind === 65 && !ts.nodeIsMissing(node)) { + var identifier = node; + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } } @@ -35693,6 +36346,8 @@ var ts; } function getEncodedSyntacticClassifications(fileName, span) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var spanStart = span.start; + var spanLength = span.length; var triviaScanner = ts.createScanner(2, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2, false, sourceFile.text); var result = []; @@ -35703,35 +36358,36 @@ var ts; result.push(length); result.push(type); } - function classifyLeadingTrivia(token) { - var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); - if (tokenStart === token.pos) { - return; - } + function classifyLeadingTriviaAndGetTokenStart(token) { triviaScanner.setTextPos(token.pos); while (true) { var start = triviaScanner.getTextPos(); + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; if (!ts.isTrivia(kind)) { - return; + return start; } - if (ts.textSpanIntersectsWith(span, start, width)) { - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); + if (kind === 4 || kind === 5) { + continue; + } + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + triviaScanner.setTextPos(end); + continue; + } + if (kind === 6) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + if (ch === 60 || ch === 62) { + pushClassification(start, width, 1); continue; } - if (kind === 6) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - if (ch === 60 || ch === 62) { - pushClassification(start, width, 1); - continue; - } - ts.Debug.assert(ch === 61); - classifyDisabledMergeCode(text, start, end); - } + ts.Debug.assert(ch === 61); + classifyDisabledMergeCode(text, start, end); } } } @@ -35760,16 +36416,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 247: + case 249: processJSDocParameterTag(tag); break; - case 250: + case 252: processJSDocTemplateTag(tag); break; - case 249: + case 251: processElement(tag.typeExpression); break; - case 248: + case 250: processElement(tag.typeExpression); break; } @@ -35825,11 +36481,16 @@ var ts; } } function classifyToken(token) { - classifyLeadingTrivia(token); - if (token.getWidth() > 0) { + if (ts.nodeIsMissing(token)) { + return; + } + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { var type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -35845,16 +36506,16 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 53) { - if (token.parent.kind === 199 || - token.parent.kind === 133 || - token.parent.kind === 130) { + if (token.parent.kind === 201 || + token.parent.kind === 134 || + token.parent.kind === 131) { return 5; } } - if (token.parent.kind === 170 || - token.parent.kind === 168 || - token.parent.kind === 169 || - token.parent.kind === 171) { + if (token.parent.kind === 172 || + token.parent.kind === 170 || + token.parent.kind === 171 || + token.parent.kind === 173) { return 5; } } @@ -35875,32 +36536,32 @@ var ts; else if (tokenKind === 65) { if (token) { switch (token.parent.kind) { - case 202: + case 204: if (token.parent.name === token) { return 11; } return; - case 129: + case 130: if (token.parent.name === token) { return 15; } return; - case 203: + case 205: if (token.parent.name === token) { return 13; } return; - case 205: + case 207: if (token.parent.name === token) { return 12; } return; - case 206: + case 208: if (token.parent.name === token) { return 14; } return; - case 130: + case 131: if (token.parent.name === token) { return 17; } @@ -35914,10 +36575,10 @@ var ts; if (!element) { return; } - if (ts.textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { var children = element.getChildren(sourceFile); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; if (ts.isToken(child)) { classifyToken(child); } @@ -36169,7 +36830,7 @@ var ts; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 220 || + node.parent.kind === 222 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -36182,7 +36843,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 157 && + node.parent.kind === 159 && node.parent.argumentExpression === node; } function createClassifier() { @@ -36204,7 +36865,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 || - keyword2 === 121 || + keyword2 === 122 || keyword2 === 114 || keyword2 === 109) { return true; @@ -36320,10 +36981,10 @@ var ts; angleBracketStack--; } else if (token === 112 || - token === 122 || - token === 120 || + token === 123 || + token === 121 || token === 113 || - token === 123) { + token === 124) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 65; } @@ -36477,7 +37138,7 @@ var ts; } } function isKeyword(token) { - return token >= 66 && token <= 126; + return token >= 66 && token <= 127; } function classFromKind(token) { if (isKeyword(token)) { @@ -36529,7 +37190,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 228 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 230 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -36547,7 +37208,6 @@ var ts; })(ts || (ts = {})); /// /// -/// /// /// var ts; @@ -36570,7 +37230,7 @@ var ts; if (a < b) { return -1; } - else if (a == b) { + else if (a === b) { return 0; } else @@ -36582,7 +37242,7 @@ var ts; } else if (a.file == b.file) { var n = compareNumber(a.start.line, b.start.line); - if (n == 0) { + if (n === 0) { return compareNumber(a.start.offset, b.start.offset); } else @@ -36639,9 +37299,11 @@ var ts; Errors.NoProject = new Error("No Project."); })(Errors || (Errors = {})); var Session = (function () { - function Session(host, logger) { + function Session(host, byteLength, hrtime, logger) { var _this = this; this.host = host; + this.byteLength = byteLength; + this.hrtime = hrtime; this.logger = logger; this.pendingOperation = false; this.fileHash = {}; @@ -36656,7 +37318,7 @@ var ts; var _this = this; if (eventName == "context") { this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n == _this.changeSeq; }, 100); + this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); } }; Session.prototype.logError = function (err, cmd) { @@ -36678,7 +37340,7 @@ var ts; if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); } - this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) + + this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + '\r\n\r\n' + json); }; Session.prototype.event = function (info, eventName) { @@ -37015,7 +37677,7 @@ var ts; var position = compilerService.host.lineOffsetToPosition(file, line, offset); var formatOptions = this.projectService.getFormatCodeOptions(file); var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); - if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) { + if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { var scriptInfo = compilerService.host.getScriptInfo(file); if (scriptInfo) { var lineInfo = scriptInfo.getLineInfo(line); @@ -37081,7 +37743,7 @@ var ts; return undefined; } return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) == 0)) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { result.push(entry); } return result; @@ -37139,7 +37801,7 @@ var ts; return accum; }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } }; Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { @@ -37154,7 +37816,7 @@ var ts; compilerService.host.editScript(file, start, end, insertString); this.changeSeq++; } - this.updateProjectStructure(this.changeSeq, function (n) { return n == _this.changeSeq; }); + this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); } }; Session.prototype.reload = function (fileName, tempFileName, reqSeq) { @@ -37270,7 +37932,7 @@ var ts; Session.prototype.onMessage = function (message) { if (this.logger.isVerbose()) { this.logger.info("request: " + message); - var start = process.hrtime(); + var start = this.hrtime(); } try { var request = JSON.parse(message); @@ -37409,7 +38071,7 @@ var ts; } } if (this.logger.isVerbose()) { - var elapsed = process.hrtime(start); + var elapsed = this.hrtime(start); var seconds = elapsed[0]; var nanoseconds = elapsed[1]; var elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; @@ -37442,7 +38104,6 @@ var ts; /// /// /// -/// var ts; (function (ts) { var server; @@ -37466,7 +38127,7 @@ var ts; this.isOpen = isOpen; this.children = []; this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); - this.svc = ScriptVersionCache.fromString(content); + this.svc = ScriptVersionCache.fromString(host, content); } ScriptInfo.prototype.setFormatOptions = function (formatOptions) { if (formatOptions) { @@ -37501,6 +38162,7 @@ var ts; }; return ScriptInfo; })(); + server.ScriptInfo = ScriptInfo; var LSHost = (function () { function LSHost(host, project) { this.host = host; @@ -37631,6 +38293,7 @@ var ts; }; return LSHost; })(); + server.LSHost = LSHost; function getAbsolutePath(filename, directory) { var rootLength = ts.getRootLength(filename); if (rootLength > 0) { @@ -37931,7 +38594,7 @@ var ts; var orphanFiles = []; for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var f = this.openFilesReferenced[i]; - if (f.defaultProject == removedProject) { + if (f.defaultProject === removedProject) { f.defaultProject = undefined; orphanFiles.push(f); } @@ -37955,7 +38618,7 @@ var ts; for (var i = 0, len = this.inferredProjects.length; i < len; i++) { var inferredProject = this.inferredProjects[i]; inferredProject.updateGraph(); - if (inferredProject != excludedProject) { + if (inferredProject !== excludedProject) { if (inferredProject.getSourceFile(info)) { info.defaultProject = inferredProject; referencingProjects.push(inferredProject); @@ -37993,7 +38656,7 @@ var ts; var rootFile = this.openFileRoots[i]; var rootedProject = rootFile.defaultProject; var referencingProjects = this.findReferencingProjects(rootFile, rootedProject); - if (referencingProjects.length == 0) { + if (referencingProjects.length === 0) { rootFile.defaultProject = rootedProject; openFileRoots.push(rootFile); } @@ -38167,7 +38830,7 @@ var ts; return rawConfig.error; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath); + var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } @@ -38228,7 +38891,7 @@ var ts; CompilerService.defaultFormatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys.newLine, + NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', ConvertTabsToSpaces: true, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, @@ -38241,7 +38904,7 @@ var ts; }; return CompilerService; })(); - var CharRangeSection; + server.CompilerService = CompilerService; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -38249,7 +38912,8 @@ var ts; CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection || (CharRangeSection = {})); + })(server.CharRangeSection || (server.CharRangeSection = {})); + var CharRangeSection = server.CharRangeSection; var BaseLineIndexWalker = (function () { function BaseLineIndexWalker() { this.goSubtree = true; @@ -38294,7 +38958,7 @@ var ts; var lastZeroCount; for (var k = this.endBranch.length - 1; k >= 0; k--) { this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() == 0) { + if (this.endBranch[k].charCount() === 0) { lastZeroCount = this.endBranch[k]; if (k > 0) { branchParent = this.endBranch[k - 1]; @@ -38350,7 +39014,7 @@ var ts; return this.lineIndex; }; EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { - if (lineCollection == this.lineCollectionAtBranch) { + if (lineCollection === this.lineCollectionAtBranch) { this.state = CharRangeSection.End; } this.stack.length--; @@ -38358,7 +39022,7 @@ var ts; }; EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; - if ((this.state == CharRangeSection.Entire) && (nodeType == CharRangeSection.Start)) { + if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { this.state = CharRangeSection.Start; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; @@ -38374,12 +39038,12 @@ var ts; switch (nodeType) { case CharRangeSection.PreStart: this.goSubtree = false; - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { currentNode.add(lineCollection); } break; case CharRangeSection.Start: - if (this.state == CharRangeSection.End) { + if (this.state === CharRangeSection.End) { this.goSubtree = false; } else { @@ -38389,7 +39053,7 @@ var ts; } break; case CharRangeSection.Entire: - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { child = fresh(lineCollection); currentNode.add(child); this.startPath[this.startPath.length] = child; @@ -38406,7 +39070,7 @@ var ts; this.goSubtree = false; break; case CharRangeSection.End: - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { this.goSubtree = false; } else { @@ -38419,7 +39083,7 @@ var ts; break; case CharRangeSection.PostEnd: this.goSubtree = false; - if (this.state != CharRangeSection.Start) { + if (this.state !== CharRangeSection.Start) { currentNode.add(lineCollection); } break; @@ -38430,10 +39094,10 @@ var ts; return lineCollection; }; EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state == CharRangeSection.Start) { + if (this.state === CharRangeSection.Start) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state == CharRangeSection.Entire) { + else if (this.state === CharRangeSection.Entire) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -38454,6 +39118,7 @@ var ts; }; return TextChange; })(); + server.TextChange = TextChange; var ScriptVersionCache = (function () { function ScriptVersionCache() { this.changes = []; @@ -38479,7 +39144,7 @@ var ts; return this.currentVersion; }; ScriptVersionCache.prototype.reloadFromFile = function (filename, cb) { - var content = ts.sys.readFile(filename); + var content = this.host.readFile(filename); this.reload(content); if (cb) cb(); @@ -38542,10 +39207,11 @@ var ts; return ts.unchangedTextChangeRange; } }; - ScriptVersionCache.fromString = function (script) { + ScriptVersionCache.fromString = function (host, script) { var svc = new ScriptVersionCache(); var snap = new LineIndexSnapshot(0, svc); svc.versions[svc.currentVersion] = snap; + svc.host = host; snap.index = new LineIndex(); var lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); @@ -38600,6 +39266,7 @@ var ts; }; return LineIndexSnapshot; })(); + server.LineIndexSnapshot = LineIndexSnapshot; var LineIndex = (function () { function LineIndex() { this.checkEdits = false; @@ -38673,7 +39340,7 @@ var ts; if (nt === void 0) { nt = ""; } return source.substring(0, s) + nt + source.substring(s + dl, source.length); } - if (this.root.charCount() == 0) { + if (this.root.charCount() === 0) { if (newText) { this.load(LineIndex.linesFromText(newText).lines); return this; @@ -38699,7 +39366,7 @@ var ts; else if (deleteLength > 0) { var e = pos + deleteLength; var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset == 0))) { + if ((lineInfo && (lineInfo.offset === 0))) { deleteLength += lineInfo.text.length; if (newText) { newText = newText + lineInfo.text; @@ -38742,7 +39409,7 @@ var ts; interiorNodes[i].totalChars = charCount; interiorNodes[i].totalLines = lineCount; } - if (interiorNodes.length == 1) { + if (interiorNodes.length === 1) { return interiorNodes[0]; } else { @@ -38751,7 +39418,7 @@ var ts; }; LineIndex.linesFromText = function (text) { var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length == 0) { + if (lineStarts.length === 0) { return { lines: [], lineMap: lineStarts }; } var lines = new Array(lineStarts.length); @@ -38972,7 +39639,7 @@ var ts; LineNode.prototype.findChildIndex = function (child) { var childIndex = 0; var clen = this.children.length; - while ((this.children[childIndex] != child) && (childIndex < clen)) + while ((this.children[childIndex] !== child) && (childIndex < clen)) childIndex++; return childIndex; }; @@ -38980,7 +39647,7 @@ var ts; var childIndex = this.findChildIndex(child); var clen = this.children.length; var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex == (clen - 1)) && (nodeCount == 1)) { + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { this.add(nodes[0]); this.updateCounts(); return []; @@ -39004,13 +39671,13 @@ var ts; var splitNode = splitNodes[0]; while (nodeIndex < nodeCount) { splitNode.add(nodes[nodeIndex++]); - if (splitNode.children.length == lineCollectionCapacity) { + if (splitNode.children.length === lineCollectionCapacity) { splitNodeIndex++; splitNode = splitNodes[splitNodeIndex]; } } for (i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length == 0) { + if (splitNodes[i].children.length === 0) { splitNodes.length--; } } @@ -39037,6 +39704,7 @@ var ts; }; return LineNode; })(); + server.LineNode = LineNode; var LineLeaf = (function () { function LineLeaf(text) { this.text = text; @@ -39061,6 +39729,7 @@ var ts; }; return LineLeaf; })(); + server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); /// @@ -39170,7 +39839,7 @@ var ts; if (err) { watchedFile.callback(watchedFile.fileName); } - else if (watchedFile.mtime.getTime() != stats.mtime.getTime()) { + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); watchedFile.callback(watchedFile.fileName); } @@ -39182,7 +39851,7 @@ var ts; var count = 0; var nextToCheck = _this.nextFileToCheck; var firstCheck = -1; - while ((count < _this.chunkSize) && (nextToCheck != firstCheck)) { + while ((count < _this.chunkSize) && (nextToCheck !== firstCheck)) { _this.poll(nextToCheck); if (firstCheck < 0) { firstCheck = nextToCheck; @@ -39216,7 +39885,7 @@ var ts; var IOSession = (function (_super) { __extends(IOSession, _super); function IOSession(host, logger) { - _super.call(this, host, logger); + _super.call(this, host, Buffer.byteLength, process.hrtime, logger); } IOSession.prototype.exit = function () { this.projectService.log("Exiting...", "Info"); diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index c8e4ae8bc69..e7637e0bc19 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -17,6 +17,13 @@ declare module "typescript" { interface Map { [index: string]: T; } + interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + remove(fileName: string): void; + forEachValue(f: (v: T) => void): void; + } interface TextRange { pos: number; end: number; @@ -139,156 +146,158 @@ declare module "typescript" { ConstructorKeyword = 114, DeclareKeyword = 115, GetKeyword = 116, - ModuleKeyword = 117, - NamespaceKeyword = 118, - RequireKeyword = 119, - NumberKeyword = 120, - SetKeyword = 121, - StringKeyword = 122, - SymbolKeyword = 123, - TypeKeyword = 124, - FromKeyword = 125, - OfKeyword = 126, - QualifiedName = 127, - ComputedPropertyName = 128, - TypeParameter = 129, - Parameter = 130, - Decorator = 131, - PropertySignature = 132, - PropertyDeclaration = 133, - MethodSignature = 134, - MethodDeclaration = 135, - Constructor = 136, - GetAccessor = 137, - SetAccessor = 138, - CallSignature = 139, - ConstructSignature = 140, - IndexSignature = 141, - TypeReference = 142, - FunctionType = 143, - ConstructorType = 144, - TypeQuery = 145, - TypeLiteral = 146, - ArrayType = 147, - TupleType = 148, - UnionType = 149, - ParenthesizedType = 150, - ObjectBindingPattern = 151, - ArrayBindingPattern = 152, - BindingElement = 153, - ArrayLiteralExpression = 154, - ObjectLiteralExpression = 155, - PropertyAccessExpression = 156, - ElementAccessExpression = 157, - CallExpression = 158, - NewExpression = 159, - TaggedTemplateExpression = 160, - TypeAssertionExpression = 161, - ParenthesizedExpression = 162, - FunctionExpression = 163, - ArrowFunction = 164, - DeleteExpression = 165, - TypeOfExpression = 166, - VoidExpression = 167, - PrefixUnaryExpression = 168, - PostfixUnaryExpression = 169, - BinaryExpression = 170, - ConditionalExpression = 171, - TemplateExpression = 172, - YieldExpression = 173, - SpreadElementExpression = 174, - ClassExpression = 175, - OmittedExpression = 176, - ExpressionWithTypeArguments = 177, - TemplateSpan = 178, - SemicolonClassElement = 179, - Block = 180, - VariableStatement = 181, - EmptyStatement = 182, - ExpressionStatement = 183, - IfStatement = 184, - DoStatement = 185, - WhileStatement = 186, - ForStatement = 187, - ForInStatement = 188, - ForOfStatement = 189, - ContinueStatement = 190, - BreakStatement = 191, - ReturnStatement = 192, - WithStatement = 193, - SwitchStatement = 194, - LabeledStatement = 195, - ThrowStatement = 196, - TryStatement = 197, - DebuggerStatement = 198, - VariableDeclaration = 199, - VariableDeclarationList = 200, - FunctionDeclaration = 201, - ClassDeclaration = 202, - InterfaceDeclaration = 203, - TypeAliasDeclaration = 204, - EnumDeclaration = 205, - ModuleDeclaration = 206, - ModuleBlock = 207, - CaseBlock = 208, - ImportEqualsDeclaration = 209, - ImportDeclaration = 210, - ImportClause = 211, - NamespaceImport = 212, - NamedImports = 213, - ImportSpecifier = 214, - ExportAssignment = 215, - ExportDeclaration = 216, - NamedExports = 217, - ExportSpecifier = 218, - MissingDeclaration = 219, - ExternalModuleReference = 220, - CaseClause = 221, - DefaultClause = 222, - HeritageClause = 223, - CatchClause = 224, - PropertyAssignment = 225, - ShorthandPropertyAssignment = 226, - EnumMember = 227, - SourceFile = 228, - JSDocTypeExpression = 229, - JSDocAllType = 230, - JSDocUnknownType = 231, - JSDocArrayType = 232, - JSDocUnionType = 233, - JSDocTupleType = 234, - JSDocNullableType = 235, - JSDocNonNullableType = 236, - JSDocRecordType = 237, - JSDocRecordMember = 238, - JSDocTypeReference = 239, - JSDocOptionalType = 240, - JSDocFunctionType = 241, - JSDocVariadicType = 242, - JSDocConstructorType = 243, - JSDocThisType = 244, - JSDocComment = 245, - JSDocTag = 246, - JSDocParameterTag = 247, - JSDocReturnTag = 248, - JSDocTypeTag = 249, - JSDocTemplateTag = 250, - SyntaxList = 251, - Count = 252, + IsKeyword = 117, + ModuleKeyword = 118, + NamespaceKeyword = 119, + RequireKeyword = 120, + NumberKeyword = 121, + SetKeyword = 122, + StringKeyword = 123, + SymbolKeyword = 124, + TypeKeyword = 125, + FromKeyword = 126, + OfKeyword = 127, + QualifiedName = 128, + ComputedPropertyName = 129, + TypeParameter = 130, + Parameter = 131, + Decorator = 132, + PropertySignature = 133, + PropertyDeclaration = 134, + MethodSignature = 135, + MethodDeclaration = 136, + Constructor = 137, + GetAccessor = 138, + SetAccessor = 139, + CallSignature = 140, + ConstructSignature = 141, + IndexSignature = 142, + TypePredicate = 143, + TypeReference = 144, + FunctionType = 145, + ConstructorType = 146, + TypeQuery = 147, + TypeLiteral = 148, + ArrayType = 149, + TupleType = 150, + UnionType = 151, + ParenthesizedType = 152, + ObjectBindingPattern = 153, + ArrayBindingPattern = 154, + BindingElement = 155, + ArrayLiteralExpression = 156, + ObjectLiteralExpression = 157, + PropertyAccessExpression = 158, + ElementAccessExpression = 159, + CallExpression = 160, + NewExpression = 161, + TaggedTemplateExpression = 162, + TypeAssertionExpression = 163, + ParenthesizedExpression = 164, + FunctionExpression = 165, + ArrowFunction = 166, + DeleteExpression = 167, + TypeOfExpression = 168, + VoidExpression = 169, + PrefixUnaryExpression = 170, + PostfixUnaryExpression = 171, + BinaryExpression = 172, + ConditionalExpression = 173, + TemplateExpression = 174, + YieldExpression = 175, + SpreadElementExpression = 176, + ClassExpression = 177, + OmittedExpression = 178, + ExpressionWithTypeArguments = 179, + TemplateSpan = 180, + SemicolonClassElement = 181, + Block = 182, + VariableStatement = 183, + EmptyStatement = 184, + ExpressionStatement = 185, + IfStatement = 186, + DoStatement = 187, + WhileStatement = 188, + ForStatement = 189, + ForInStatement = 190, + ForOfStatement = 191, + ContinueStatement = 192, + BreakStatement = 193, + ReturnStatement = 194, + WithStatement = 195, + SwitchStatement = 196, + LabeledStatement = 197, + ThrowStatement = 198, + TryStatement = 199, + DebuggerStatement = 200, + VariableDeclaration = 201, + VariableDeclarationList = 202, + FunctionDeclaration = 203, + ClassDeclaration = 204, + InterfaceDeclaration = 205, + TypeAliasDeclaration = 206, + EnumDeclaration = 207, + ModuleDeclaration = 208, + ModuleBlock = 209, + CaseBlock = 210, + ImportEqualsDeclaration = 211, + ImportDeclaration = 212, + ImportClause = 213, + NamespaceImport = 214, + NamedImports = 215, + ImportSpecifier = 216, + ExportAssignment = 217, + ExportDeclaration = 218, + NamedExports = 219, + ExportSpecifier = 220, + MissingDeclaration = 221, + ExternalModuleReference = 222, + CaseClause = 223, + DefaultClause = 224, + HeritageClause = 225, + CatchClause = 226, + PropertyAssignment = 227, + ShorthandPropertyAssignment = 228, + EnumMember = 229, + SourceFile = 230, + JSDocTypeExpression = 231, + JSDocAllType = 232, + JSDocUnknownType = 233, + JSDocArrayType = 234, + JSDocUnionType = 235, + JSDocTupleType = 236, + JSDocNullableType = 237, + JSDocNonNullableType = 238, + JSDocRecordType = 239, + JSDocRecordMember = 240, + JSDocTypeReference = 241, + JSDocOptionalType = 242, + JSDocFunctionType = 243, + JSDocVariadicType = 244, + JSDocConstructorType = 245, + JSDocThisType = 246, + JSDocComment = 247, + JSDocTag = 248, + JSDocParameterTag = 249, + JSDocReturnTag = 250, + JSDocTypeTag = 251, + JSDocTemplateTag = 252, + SyntaxList = 253, + Count = 254, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, LastReservedWord = 101, FirstKeyword = 66, - LastKeyword = 126, + LastKeyword = 127, FirstFutureReservedWord = 102, LastFutureReservedWord = 110, - FirstTypeNode = 142, - LastTypeNode = 150, + FirstTypeNode = 144, + LastTypeNode = 152, FirstPunctuation = 14, LastPunctuation = 64, FirstToken = 0, - LastToken = 126, + LastToken = 127, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -297,7 +306,7 @@ declare module "typescript" { LastTemplateToken = 13, FirstBinaryOperator = 24, LastBinaryOperator = 64, - FirstNode = 127, + FirstNode = 128, } const enum NodeFlags { Export = 1, @@ -458,6 +467,10 @@ declare module "typescript" { typeName: EntityName; typeArguments?: NodeArray; } + interface TypePredicateNode extends TypeNode { + parameterName: Identifier; + type: TypeNode; + } interface TypeQueryNode extends TypeNode { exprName: EntityName; } @@ -587,12 +600,12 @@ declare module "typescript" { tag: LeftHandSideExpression; template: LiteralExpression | TemplateExpression; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } - interface Statement extends Node, ModuleElement { + interface Statement extends Node { _statementBrand: any; } interface Block extends Statement { @@ -672,9 +685,6 @@ declare module "typescript" { variableDeclaration: VariableDeclaration; block: Block; } - interface ModuleElement extends Node { - _moduleElementBrand: any; - } interface ClassLikeDeclaration extends Declaration { name?: Identifier; typeParameters?: NodeArray; @@ -700,6 +710,7 @@ declare module "typescript" { } interface TypeAliasDeclaration extends Declaration, Statement { name: Identifier; + typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { @@ -710,21 +721,21 @@ declare module "typescript" { name: Identifier; members: NodeArray; } - interface ModuleDeclaration extends Declaration, ModuleElement { + interface ModuleDeclaration extends Declaration, Statement { name: Identifier | LiteralExpression; body: ModuleBlock | ModuleDeclaration; } - interface ModuleBlock extends Node, ModuleElement { - statements: NodeArray; + interface ModuleBlock extends Node, Statement { + statements: NodeArray; } - interface ImportEqualsDeclaration extends Declaration, ModuleElement { + interface ImportEqualsDeclaration extends Declaration, Statement { name: Identifier; moduleReference: EntityName | ExternalModuleReference; } interface ExternalModuleReference extends Node { expression?: Expression; } - interface ImportDeclaration extends ModuleElement { + interface ImportDeclaration extends Statement { importClause?: ImportClause; moduleSpecifier: Expression; } @@ -735,7 +746,7 @@ declare module "typescript" { interface NamespaceImport extends Declaration { name: Identifier; } - interface ExportDeclaration extends Declaration, ModuleElement { + interface ExportDeclaration extends Declaration, Statement { exportClause?: NamedExports; moduleSpecifier?: Expression; } @@ -750,7 +761,7 @@ declare module "typescript" { } type ImportSpecifier = ImportOrExportSpecifier; type ExportSpecifier = ImportOrExportSpecifier; - interface ExportAssignment extends Declaration, ModuleElement { + interface ExportAssignment extends Declaration, Statement { isExportEquals?: boolean; expression: Expression; } @@ -838,7 +849,7 @@ declare module "typescript" { isBracketed: boolean; } interface SourceFile extends Declaration { - statements: NodeArray; + statements: NodeArray; endOfFileToken: Node; fileName: string; text: string; @@ -846,8 +857,16 @@ declare module "typescript" { path: string; name: string; }[]; - amdModuleName: string; + moduleName: string; referencedFiles: FileReference[]; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } @@ -878,8 +897,9 @@ declare module "typescript" { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; /** @@ -998,6 +1018,11 @@ declare module "typescript" { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } + interface TypePredicate { + parameterName: string; + parameterIndex: number; + type: Type; + } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -1060,6 +1085,7 @@ declare module "typescript" { ExportHasLocal = 944, HasExports = 1952, HasMembers = 6240, + BlockScoped = 418, PropertyOrAccessor = 98308, Export = 7340032, } @@ -1111,9 +1137,8 @@ declare module "typescript" { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - } - interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; + resolvedBaseConstructorType?: Type; + resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1146,6 +1171,7 @@ declare module "typescript" { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; + typePredicate?: TypePredicate; } const enum IndexKind { String = 0, @@ -1323,6 +1349,7 @@ declare module "typescript" { function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; @@ -1338,6 +1365,7 @@ declare module "typescript" { function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; function createTextSpan(start: number, length: number): TextSpan; @@ -1490,6 +1518,7 @@ declare module "typescript" { log?(s: string): void; trace?(s: string): void; error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; } interface LanguageService { cleanupSemanticCache(): void; @@ -1948,11 +1977,11 @@ declare module "typescript" { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } - function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createDocumentRegistry(): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/bin/typescript.js b/bin/typescript.js index 3dd6dd919be..6373e3f9c58 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -144,176 +144,178 @@ var ts; SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 118] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 119] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 120] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 121] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 122] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 123] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 124] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 125] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 126] = "OfKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 117] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 118] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 119] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 120] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 121] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 122] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 123] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 124] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 125] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 126] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 127] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 127] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 128] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 128] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 129] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 129] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 130] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 131] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 130] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 131] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 132] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 132] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 133] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 134] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 135] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 136] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 137] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 138] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 139] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 140] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 141] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 133] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 134] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 135] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 136] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 137] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 138] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 139] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 140] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 141] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 142] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypeReference"] = 142] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 143] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 144] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 145] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 146] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 147] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 148] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 149] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 150] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 143] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 144] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 145] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 146] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 147] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 148] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 149] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 150] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 151] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 152] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 151] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 152] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 153] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 153] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 154] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 155] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 154] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 155] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 156] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 157] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 158] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 159] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 160] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 161] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 162] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 163] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 164] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 165] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 166] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 167] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 168] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 169] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 170] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 171] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 172] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 173] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 174] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 175] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 176] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 177] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 156] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 157] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 158] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 159] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 160] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 161] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 162] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 163] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 164] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 165] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 166] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 167] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 168] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 169] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 170] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 171] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 172] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 174] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 175] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 176] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 177] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 178] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 179] = "ExpressionWithTypeArguments"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 178] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 179] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 180] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 181] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 180] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 181] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 182] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 183] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 184] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 185] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 186] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 187] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 188] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 189] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 190] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 191] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 192] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 193] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 194] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 195] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 196] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 197] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 198] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 199] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 200] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 201] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 202] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 203] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 204] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 205] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 206] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 207] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 208] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 209] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 210] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 211] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 212] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 213] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 214] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 215] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 216] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 217] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 218] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 219] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 182] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 183] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 184] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 185] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 186] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 187] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 188] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 189] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 190] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 191] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 192] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 193] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 194] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 195] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 196] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 197] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 198] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 199] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 200] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 201] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 202] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 203] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 204] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 205] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 206] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 207] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 208] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 209] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 210] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 211] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 212] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 213] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 214] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 215] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 216] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 217] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 218] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 219] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 220] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 221] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 220] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 222] = "ExternalModuleReference"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 221] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 222] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 223] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 224] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 223] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 224] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 225] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 226] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 225] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 226] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 227] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 228] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 227] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 229] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 228] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 230] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 229] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 231] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 230] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 232] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 231] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 232] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 233] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 234] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 235] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 236] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 237] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 238] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 239] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 240] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 241] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 242] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 243] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 244] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 245] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 246] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 247] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 248] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 249] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 250] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 233] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 234] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 235] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 236] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 237] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 238] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 239] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 240] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 241] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 242] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 243] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 244] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 245] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 246] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 247] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 248] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 249] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 250] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 251] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 252] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 251] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 253] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 252] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 254] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 126] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 127] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 142] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 150] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 144] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 152] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 126] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 127] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -322,7 +324,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 127] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 128] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -349,9 +351,6 @@ var ts; /* @internal */ (function (ParserContextFlags) { ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // Set if this node was parsed in strict mode. Used for grammar error checks, as well as - // checking if the node can be reused in incremental settings. - ParserContextFlags[ParserContextFlags["StrictMode"] = 1] = "StrictMode"; // If this node was parsed in a context where 'in-expressions' are not allowed. ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; // If this node was parsed in the 'yield' context created when parsing a generator. @@ -368,7 +367,7 @@ var ts; // its type can be specified usign a JSDoc comment. ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 64] = "JavaScriptFile"; // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 62] = "ParserGeneratedFlags"; // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. @@ -494,8 +493,13 @@ var ts; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + /* @internal */ + // The set of things we consider semantically classifiable. Used to speed up the LS during + // classification. + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(ts.SymbolFlags || (ts.SymbolFlags = {})); var SymbolFlags = ts.SymbolFlags; /* @internal */ @@ -735,6 +739,36 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -1232,7 +1266,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { // If the path is not rooted it is relative to current directory path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); @@ -1896,14 +1930,32 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2097,6 +2149,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, 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}'." }, @@ -2274,9 +2331,7 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } }; })(ts || (ts = {})); /// @@ -2306,7 +2361,7 @@ var ts; "false": 80 /* FalseKeyword */, "finally": 81 /* FinallyKeyword */, "for": 82 /* ForKeyword */, - "from": 125 /* FromKeyword */, + "from": 126 /* FromKeyword */, "function": 83 /* FunctionKeyword */, "get": 116 /* GetKeyword */, "if": 84 /* IfKeyword */, @@ -2315,36 +2370,37 @@ var ts; "in": 86 /* InKeyword */, "instanceof": 87 /* InstanceOfKeyword */, "interface": 103 /* InterfaceKeyword */, + "is": 117 /* IsKeyword */, "let": 104 /* LetKeyword */, - "module": 117 /* ModuleKeyword */, - "namespace": 118 /* NamespaceKeyword */, + "module": 118 /* ModuleKeyword */, + "namespace": 119 /* NamespaceKeyword */, "new": 88 /* NewKeyword */, "null": 89 /* NullKeyword */, - "number": 120 /* NumberKeyword */, + "number": 121 /* NumberKeyword */, "package": 105 /* PackageKeyword */, "private": 106 /* PrivateKeyword */, "protected": 107 /* ProtectedKeyword */, "public": 108 /* PublicKeyword */, - "require": 119 /* RequireKeyword */, + "require": 120 /* RequireKeyword */, "return": 90 /* ReturnKeyword */, - "set": 121 /* SetKeyword */, + "set": 122 /* SetKeyword */, "static": 109 /* StaticKeyword */, - "string": 122 /* StringKeyword */, + "string": 123 /* StringKeyword */, "super": 91 /* SuperKeyword */, "switch": 92 /* SwitchKeyword */, - "symbol": 123 /* SymbolKeyword */, + "symbol": 124 /* SymbolKeyword */, "this": 93 /* ThisKeyword */, "throw": 94 /* ThrowKeyword */, "true": 95 /* TrueKeyword */, "try": 96 /* TryKeyword */, - "type": 124 /* TypeKeyword */, + "type": 125 /* TypeKeyword */, "typeof": 97 /* TypeOfKeyword */, "var": 98 /* VarKeyword */, "void": 99 /* VoidKeyword */, "while": 100 /* WhileKeyword */, "with": 101 /* WithKeyword */, "yield": 110 /* YieldKeyword */, - "of": 126 /* OfKeyword */, + "of": 127 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2604,8 +2660,31 @@ var ts; return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + // Keep in sync with skipTrivia + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + case 47 /* slash */: + // starts of normal trivia + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + // Starts of conflict marker trivia + return true; + default: + return ch > 127 /* maxAsciiCharacter */; + } + } + ts.couldStartTrivia = couldStartTrivia; /* @internal */ function skipTrivia(text, pos, stopAfterLineBreak) { + // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); switch (ch) { @@ -3109,7 +3188,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -3666,16 +3745,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 207 /* ModuleBlock */) { + else if (node.kind === 209 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3694,7 +3773,7 @@ var ts; }); return state; } - else if (node.kind === 206 /* ModuleDeclaration */) { + else if (node.kind === 208 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3734,11 +3813,17 @@ var ts; var container; var blockScopeContainer; var lastContainer; + // If this file is an external module, then it is automatically in strict-mode according to + // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -3766,10 +3851,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3777,22 +3862,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return "__constructor"; - case 143 /* FunctionType */: - case 139 /* CallSignature */: + case 145 /* FunctionType */: + case 140 /* CallSignature */: return "__call"; - case 144 /* ConstructorType */: - case 140 /* ConstructSignature */: + case 146 /* ConstructorType */: + case 141 /* ConstructSignature */: return "__new"; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return "__index"; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return "__export"; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: return node.flags & 256 /* Default */ ? "default" : undefined; } } @@ -3826,6 +3911,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0 /* None */, name)); + if (name && (includes & 788448 /* Classifiable */)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -3852,7 +3940,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 218 /* ExportSpecifier */ || (node.kind === 209 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 220 /* ExportSpecifier */ || (node.kind === 211 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3933,36 +4021,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 206 /* ModuleDeclaration */: - case 228 /* SourceFile */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 208 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 206 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 224 /* CatchClause */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 208 /* CaseBlock */: + case 226 /* CatchClause */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 210 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 180 /* Block */: + case 182 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -3995,45 +4084,47 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - // Modules, source files, and classes need specialized handling for how their + // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific - // symbol table depending on if it is static or not). As such, we defer to - // specialized handlers to take care of declaring these child members. - case 206 /* ModuleDeclaration */: + // symbol table depending on if it is static or not). We defer to specialized + // handlers to take care of declaring these child members. + case 208 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: - case 203 /* InterfaceDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: + case 205 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of - // their container. They are only accessible through an instance of their - // container, and are never in scope otherwise (even inside the body of the - // object / type / interface declaring them). + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). An exception is type parameters, + // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 206 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another - // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // they're only accessed 'lexically' (i.e. from code that exists underneath + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // they're only accessed 'lexically' (i.e. from code that exists underneath // their container in the tree. To accomplish this, we simply add their declared - // symbol to the 'locals' of the container. These symbols can then be found as + // symbol to the 'locals' of the container. These symbols can then be found as // the type checker walks up the containers, checking them for matching names. return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -4058,11 +4149,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 /* SourceFile */ ? node : node.body; - if (body.kind === 228 /* SourceFile */ || body.kind === 207 /* ModuleBlock */) { + var body = node.kind === 230 /* SourceFile */ ? node : node.body; + if (body.kind === 230 /* SourceFile */ || body.kind === 209 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 /* ExportDeclaration */ || stat.kind === 215 /* ExportAssignment */) { + if (stat.kind === 218 /* ExportDeclaration */ || stat.kind === 217 /* ExportAssignment */) { return true; } } @@ -4117,16 +4208,54 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65 /* Identifier */) { + continue; + } + var identifier = prop.name; + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + var currentKind = prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */ || prop.kind === 136 /* MethodDeclaration */ + ? 1 /* Property */ + : 2 /* Accessor */; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4143,11 +4272,126 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); } + // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized + // check for reserved words used as identifiers in strict mode code. + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 110 /* LastFutureReservedWord */ && + !ts.isIdentifierName(node)) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + // Grammar checking + if (inStrictMode && node.expression.kind === 65 /* Identifier */) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65 /* Identifier */) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384 /* OctalLiteral */) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + // Grammar checking + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + // Grammar checking + if (inStrictMode) { + if (node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -4164,76 +4408,132 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230 /* SourceFile */: + case 209 /* ModuleBlock */: + updateStrictModeStatementList(node.statements); + return; + case 182 /* Block */: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the + // string to contain unicode escapes (as per ES5). + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129 /* TypeParameter */: + case 65 /* Identifier */: + return checkStrictModeIdentifier(node); + case 172 /* BinaryExpression */: + return checkStrictModeBinaryExpression(node); + case 226 /* CatchClause */: + return checkStrictModeCatchClause(node); + case 167 /* DeleteExpression */: + return checkStrictModeDeleteExpression(node); + case 7 /* NumericLiteral */: + return checkStrictModeNumericLiteral(node); + case 171 /* PostfixUnaryExpression */: + return checkStrictModePostfixUnaryExpression(node); + case 170 /* PrefixUnaryExpression */: + return checkStrictModePrefixUnaryExpression(node); + case 195 /* WithStatement */: + return checkStrictModeWithStatement(node); + case 130 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 130 /* Parameter */: + case 131 /* Parameter */: return bindParameter(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: + checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 136 /* Constructor */: + case 137 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 155 /* ObjectLiteralExpression */: - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: + return bindObjectLiteralExpression(node); + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + checkStrictModeFunctionName(node); return bindAnonymousDeclaration(node, 16 /* Function */, "__function"); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return bindImportClause(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return bindExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return bindExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -4244,7 +4544,11 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65 /* Identifier */) { + if (!container.symbol || !container.symbol.exports) { + // Export assignment in some sort of block construct + bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); + } + else if (node.expression.kind === 65 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4254,7 +4558,11 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + // Export * in some sort of block construct + bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + } + else if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); } @@ -4265,7 +4573,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); } else { @@ -4297,6 +4605,9 @@ var ts; : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -4319,6 +4630,11 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); } @@ -4328,8 +4644,8 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 136 /* Constructor */ && - (node.parent.parent.kind === 202 /* ClassDeclaration */ || node.parent.parent.kind === 175 /* ClassExpression */)) { + node.parent.kind === 137 /* Constructor */ && + ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -4359,7 +4675,7 @@ var ts; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -4416,7 +4732,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228 /* SourceFile */) { + while (node && node.kind !== 230 /* SourceFile */) { node = node.parent; } return node; @@ -4526,15 +4842,15 @@ var ts; return current; } switch (current.kind) { - case 228 /* SourceFile */: - case 208 /* CaseBlock */: - case 224 /* CatchClause */: - case 206 /* ModuleDeclaration */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 230 /* SourceFile */: + case 210 /* CaseBlock */: + case 226 /* CatchClause */: + case 208 /* ModuleDeclaration */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return current; - case 180 /* Block */: + case 182 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4547,9 +4863,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 /* VariableDeclaration */ && + declaration.kind === 201 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 224 /* CatchClause */; + declaration.parent.kind === 226 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4588,7 +4904,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4597,16 +4913,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: errorNode = node.name; break; } @@ -4630,11 +4946,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 /* EnumDeclaration */ && isConst(node); + return node.kind === 207 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 155 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4649,14 +4965,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 200 /* VariableDeclarationList */) { + if (node && node.kind === 202 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181 /* VariableStatement */) { + if (node && node.kind === 183 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4671,12 +4987,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 185 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 130 /* Parameter */ || node.kind === 129 /* TypeParameter */) { + if (node.kind === 131 /* Parameter */ || node.kind === 130 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -4700,40 +5016,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 /* FirstTypeNode */ <= node.kind && node.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= node.kind && node.kind <= 152 /* LastTypeNode */) { return true; } switch (node.kind) { case 112 /* AnyKeyword */: - case 120 /* NumberKeyword */: - case 122 /* StringKeyword */: + case 121 /* NumberKeyword */: + case 123 /* StringKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return true; case 99 /* VoidKeyword */: - return node.parent.kind !== 167 /* VoidExpression */; + return node.parent.kind !== 169 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 130 /* Parameter */; - case 177 /* ExpressionWithTypeArguments */: - return true; + return node.parent.kind === 131 /* Parameter */; + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 65 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 127 /* QualifiedName */: - case 156 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145 /* TypeQuery */) { + if (parent_1.kind === 147 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4742,38 +5058,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (142 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 152 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 177 /* ExpressionWithTypeArguments */: - return true; - case 129 /* TypeParameter */: + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 130 /* TypeParameter */: return node === parent_1.constraint; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: return node === parent_1.type; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node === parent_1.type; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return node === parent_1.type; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_1.type; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4787,23 +5103,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitor(node); - case 208 /* CaseBlock */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 210 /* CaseBlock */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4813,17 +5129,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -4831,7 +5148,7 @@ var ts; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128 /* ComputedPropertyName */) { + if (name_4 && name_4.kind === 129 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_4.expression); @@ -4850,14 +5167,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153 /* BindingElement */: - case 227 /* EnumMember */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: return true; } } @@ -4865,38 +5182,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - if (node) { - switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - return true; - } - } - return false; + return node && (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - if (node) { - return node.kind === 202 /* ClassDeclaration */ || node.kind === 175 /* ClassExpression */; - } + return node && (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return true; } } @@ -4904,11 +5212,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 182 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 /* MethodDeclaration */ && node.parent.kind === 155 /* ObjectLiteralExpression */; + return node && node.kind === 136 /* MethodDeclaration */ && node.parent.kind === 157 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4920,6 +5228,15 @@ var ts; } } ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { while (true) { node = node.parent; @@ -4927,12 +5244,12 @@ var ts; return undefined; } switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (isClassLike(node.parent.parent)) { return node; } // If this is a computed property, then the parent should not @@ -4942,9 +5259,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -4955,23 +5272,23 @@ var ts; node = node.parent; } break; - case 164 /* ArrowFunction */: + case 166 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 206 /* ModuleDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 205 /* EnumDeclaration */: - case 228 /* SourceFile */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 208 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 207 /* EnumDeclaration */: + case 230 /* SourceFile */: return node; } } @@ -4983,12 +5300,12 @@ var ts; if (!node) return node; switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (isClassLike(node.parent.parent)) { return node; } // If this is a computed property, then the parent should not @@ -4998,9 +5315,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5011,72 +5328,72 @@ var ts; node = node.parent; } break; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { return node.tag; } - // Will either be a CallExpression or NewExpression. + // Will either be a CallExpression, NewExpression, or Decorator. return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // classes are valid targets return true; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 202 /* ClassDeclaration */; - case 130 /* Parameter */: + return node.parent.kind === 204 /* ClassDeclaration */; + case 131 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 202 /* ClassDeclaration */; - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 204 /* ClassDeclaration */; + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 202 /* ClassDeclaration */; + return node.body && node.parent.kind === 204 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: if (node.decorators) { return true; } return false; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5087,10 +5404,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5108,38 +5425,38 @@ var ts; case 95 /* TrueKeyword */: case 80 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 163 /* FunctionExpression */: - case 175 /* ClassExpression */: - case 164 /* ArrowFunction */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 172 /* TemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 165 /* FunctionExpression */: + case 177 /* ClassExpression */: + case 166 /* ArrowFunction */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 174 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 176 /* OmittedExpression */: - case 173 /* YieldExpression */: + case 178 /* OmittedExpression */: + case 175 /* YieldExpression */: return true; - case 127 /* QualifiedName */: - while (node.parent.kind === 127 /* QualifiedName */) { + case 128 /* QualifiedName */: + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 145 /* TypeQuery */; + return node.parent.kind === 147 /* TypeQuery */; case 65 /* Identifier */: - if (node.parent.kind === 145 /* TypeQuery */) { + if (node.parent.kind === 147 /* TypeQuery */) { return true; } // fall through @@ -5147,43 +5464,45 @@ var ts; case 8 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 227 /* EnumMember */: - case 225 /* PropertyAssignment */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 155 /* BindingElement */: return parent_2.initializer === node; - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 196 /* ThrowStatement */: - case 194 /* SwitchStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 198 /* ThrowStatement */: + case 196 /* SwitchStatement */: return parent_2.expression === node; - case 187 /* ForStatement */: + case 189 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forInStatement.expression === node; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_2.expression; - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return node === parent_2.expression; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return node === parent_2.expression; - case 131 /* Decorator */: + case 132 /* Decorator */: return true; + case 179 /* ExpressionWithTypeArguments */: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -5200,7 +5519,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5209,20 +5528,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 222 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 220 /* ExternalModuleReference */) { + if (reference.kind === 222 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 218 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5230,15 +5549,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: return node.questionToken !== undefined; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return node.questionToken !== undefined; - case 226 /* ShorthandPropertyAssignment */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5246,9 +5565,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 /* JSDocFunctionType */ && + return node.kind === 243 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 243 /* JSDocConstructorType */; + node.parameters[0].type.kind === 245 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5262,15 +5581,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249 /* JSDocTypeTag */); + return getJSDocTag(node, 251 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248 /* JSDocReturnTag */); + return getJSDocTag(node, 250 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250 /* JSDocTemplateTag */); + return getJSDocTag(node, 252 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5281,7 +5600,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247 /* JSDocParameterTag */) { + if (t.kind === 249 /* JSDocParameterTag */) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -5300,12 +5619,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64 /* JavaScriptFile */) { - if (node.type && node.type.kind === 242 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 244 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 244 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5326,7 +5645,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 /* ArrayBindingPattern */ || node.kind === 151 /* ObjectBindingPattern */); + return !!node && (node.kind === 154 /* ArrayBindingPattern */ || node.kind === 153 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5341,33 +5660,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164 /* ArrowFunction */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 136 /* Constructor */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 218 /* ExportSpecifier */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 211 /* ImportClause */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 203 /* InterfaceDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 206 /* ModuleDeclaration */: - case 212 /* NamespaceImport */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 138 /* SetAccessor */: - case 226 /* ShorthandPropertyAssignment */: - case 204 /* TypeAliasDeclaration */: - case 129 /* TypeParameter */: - case 199 /* VariableDeclaration */: + case 166 /* ArrowFunction */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 137 /* Constructor */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 220 /* ExportSpecifier */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 213 /* ImportClause */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 205 /* InterfaceDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 208 /* ModuleDeclaration */: + case 214 /* NamespaceImport */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 139 /* SetAccessor */: + case 228 /* ShorthandPropertyAssignment */: + case 206 /* TypeAliasDeclaration */: + case 130 /* TypeParameter */: + case 201 /* VariableDeclaration */: return true; } return false; @@ -5375,25 +5695,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 198 /* DebuggerStatement */: - case 185 /* DoStatement */: - case 183 /* ExpressionStatement */: - case 182 /* EmptyStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 195 /* LabeledStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 200 /* DebuggerStatement */: + case 187 /* DoStatement */: + case 185 /* ExpressionStatement */: + case 184 /* EmptyStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 197 /* LabeledStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: case 94 /* ThrowKeyword */: - case 197 /* TryStatement */: - case 181 /* VariableStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 215 /* ExportAssignment */: + case 199 /* TryStatement */: + case 183 /* VariableStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 217 /* ExportAssignment */: return true; default: return false; @@ -5402,13 +5722,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: return true; default: return false; @@ -5421,7 +5741,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 /* ImportSpecifier */ || parent.kind === 218 /* ExportSpecifier */) { + if (parent.kind === 216 /* ImportSpecifier */ || parent.kind === 220 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5432,6 +5752,41 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + // Return true if the given identifier is classified as an IdentifierName + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + // Name in member declaration or property name in property access + return parent.name === node; + case 128 /* QualifiedName */: + // Name on right hand side of dot in a type query + if (parent.right === node) { + while (parent.kind === 128 /* QualifiedName */) { + parent = parent.parent; + } + return parent.kind === 147 /* TypeQuery */; + } + return false; + case 155 /* BindingElement */: + case 216 /* ImportSpecifier */: + // Property name in binding element or import specifier + return parent.propertyName === node; + case 220 /* ExportSpecifier */: + // Any name in an export specifier + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; // An alias symbol is created by one of the following declarations: // import = ... // import from ... @@ -5441,12 +5796,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 211 /* ImportClause */ && !!node.name || - node.kind === 212 /* NamespaceImport */ || - node.kind === 214 /* ImportSpecifier */ || - node.kind === 218 /* ExportSpecifier */ || - node.kind === 215 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 213 /* ImportClause */ && !!node.name || + node.kind === 214 /* NamespaceImport */ || + node.kind === 216 /* ImportSpecifier */ || + node.kind === 220 /* ExportSpecifier */ || + node.kind === 217 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5529,7 +5884,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 126 /* LastKeyword */; + return 66 /* FirstKeyword */ <= token && token <= 127 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5545,7 +5900,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 /* ComputedPropertyName */ && + declaration.name.kind === 129 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5555,14 +5910,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 158 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 128 /* ComputedPropertyName */) { + if (name.kind === 129 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5600,18 +5955,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130 /* Parameter */; + return root.kind === 131 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153 /* BindingElement */) { + while (node.kind === 155 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 /* ModuleDeclaration */ || n.kind === 228 /* SourceFile */; + return isFunctionLike(n) || n.kind === 208 /* ModuleDeclaration */ || n.kind === 230 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5847,7 +6202,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -5872,10 +6227,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 138 /* SetAccessor */) { + else if (accessor.kind === 139 /* SetAccessor */) { setAccessor = accessor; } else { @@ -5884,7 +6239,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) + if ((member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5895,10 +6250,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 /* GetAccessor */ && !getAccessor) { + if (member.kind === 138 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 138 /* SetAccessor */ && !setAccessor) { + if (member.kind === 139 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6046,22 +6401,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 159 /* NewExpression */: - case 158 /* CallExpression */: - case 160 /* TaggedTemplateExpression */: - case 154 /* ArrayLiteralExpression */: - case 162 /* ParenthesizedExpression */: - case 155 /* ObjectLiteralExpression */: - case 175 /* ClassExpression */: - case 163 /* FunctionExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 161 /* NewExpression */: + case 160 /* CallExpression */: + case 162 /* TaggedTemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 164 /* ParenthesizedExpression */: + case 157 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 165 /* FunctionExpression */: case 65 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: case 80 /* FalseKeyword */: case 89 /* NullKeyword */: case 93 /* ThisKeyword */: @@ -6077,6 +6432,12 @@ var ts; return token >= 53 /* FirstAssignment */ && token <= 64 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 /* ExpressionWithTypeArguments */ && + node.parent.token === 79 /* ExtendsKeyword */ && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). function isSupportedExpressionWithTypeArguments(node) { @@ -6087,7 +6448,7 @@ var ts; if (node.kind === 65 /* Identifier */) { return true; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6095,8 +6456,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -6237,6 +6598,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -6396,9 +6763,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129 /* TypeParameter */) { + if (d && d.kind === 130 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205 /* InterfaceDeclaration */) { return current; } } @@ -6410,7 +6777,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252 /* Count */); + var nodeConstructors = new Array(254 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -6455,20 +6822,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6477,24 +6844,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6505,263 +6872,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 147 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 148 /* TupleType */: + case 150 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 149 /* UnionType */: + case 151 /* UnionType */: return visitNodes(cbNodes, node.types); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200 /* VariableDeclarationList */: + case 202 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return visitNode(cbNode, node.label); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 221 /* CaseClause */: + case 223 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 222 /* DefaultClause */: + case 224 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131 /* Decorator */: + case 132 /* Decorator */: return visitNode(cbNode, node.expression); - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 213 /* NamedImports */: - case 217 /* NamedExports */: + case 215 /* NamedImports */: + case 219 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220 /* ExternalModuleReference */: + case 222 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 229 /* JSDocTypeExpression */: + case 231 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 233 /* JSDocUnionType */: + case 235 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 234 /* JSDocTupleType */: + case 236 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 232 /* JSDocArrayType */: + case 234 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 236 /* JSDocNonNullableType */: + case 238 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 235 /* JSDocNullableType */: + case 237 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 237 /* JSDocRecordType */: + case 239 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 239 /* JSDocTypeReference */: + case 241 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240 /* JSDocOptionalType */: + case 242 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 241 /* JSDocFunctionType */: + case 243 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 242 /* JSDocVariadicType */: + case 244 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 243 /* JSDocConstructorType */: + case 245 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 244 /* JSDocThisType */: + case 246 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 238 /* JSDocRecordMember */: + case 240 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245 /* JSDocComment */: + case 247 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -6891,13 +7262,6 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - (function (StatementFlags) { - StatementFlags[StatementFlags["None"] = 0] = "None"; - StatementFlags[StatementFlags["Statement"] = 1] = "Statement"; - StatementFlags[StatementFlags["ModuleElement"] = 2] = "ModuleElement"; - StatementFlags[StatementFlags["StatementOrModuleElement"] = 3] = "StatementOrModuleElement"; - })(Parser.StatementFlags || (Parser.StatementFlags = {})); - var StatementFlags = Parser.StatementFlags; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); @@ -6936,7 +7300,7 @@ var ts; // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); ts.Debug.assert(token === 1 /* EndOfFileToken */); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -6962,9 +7326,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 130 /* Parameter */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 131 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7005,7 +7369,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228 /* SourceFile */, 0); + var sourceFile = createNode(230 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7023,9 +7387,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1 /* StrictMode */); - } function setDisallowInContext(val) { setContextFlag(val, 2 /* DisallowIn */); } @@ -7102,9 +7463,6 @@ var ts; function inYieldContext() { return (contextFlags & 4 /* Yield */) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1 /* StrictMode */) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8 /* GeneratorParameter */) !== 0; } @@ -7356,7 +7714,7 @@ var ts; // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] // - var node = createNode(128 /* ComputedPropertyName */); + var node = createNode(129 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -7414,37 +7772,34 @@ var ts; } switch (parsingContext) { case 0 /* SourceElements */: - case 1 /* ModuleElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfModuleElement(); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: - // During error recovery we don't treat empty statements as statements return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isStartOfTypeMember(); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); - case 10 /* ObjectBindingElements */: + case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. if (token === 14 /* OpenBraceToken */) { @@ -7459,29 +7814,29 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); - case 11 /* ArrayBindingElements */: + case 10 /* ArrayBindingElements */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: return isIdentifier(); - case 12 /* ArgumentExpressions */: - case 14 /* ArrayLiteralMembers */: + case 11 /* ArgumentExpressions */: + case 13 /* ArrayLiteralMembers */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); - case 15 /* Parameters */: + case 14 /* Parameters */: return isStartOfParameter(); - case 17 /* TypeArguments */: - case 18 /* TupleElementTypes */: + case 16 /* TypeArguments */: + case 17 /* TupleElementTypes */: return token === 23 /* CommaToken */ || isStartOfType(); - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return isHeritageClause(); - case 20 /* ImportOrExportSpecifiers */: + case 19 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); - case 21 /* JSDocFunctionParameters */: - case 22 /* JSDocTypeArguments */: - case 24 /* JSDocTupleTypes */: + case 20 /* JSDocFunctionParameters */: + case 21 /* JSDocTypeArguments */: + case 23 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -7523,47 +7878,46 @@ var ts; return true; } switch (kind) { - case 1 /* ModuleElements */: - case 2 /* BlockStatements */: - case 3 /* SwitchClauses */: - case 5 /* TypeMembers */: - case 6 /* ClassMembers */: - case 7 /* EnumMembers */: - case 13 /* ObjectLiteralMembers */: - case 10 /* ObjectBindingElements */: - case 20 /* ImportOrExportSpecifiers */: + case 1 /* BlockStatements */: + case 2 /* SwitchClauses */: + case 4 /* TypeMembers */: + case 5 /* ClassMembers */: + case 6 /* EnumMembers */: + case 12 /* ObjectLiteralMembers */: + case 9 /* ObjectBindingElements */: + case 19 /* ImportOrExportSpecifiers */: return token === 15 /* CloseBraceToken */; - case 4 /* SwitchClauseStatements */: + case 3 /* SwitchClauseStatements */: return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; - case 14 /* ArrayLiteralMembers */: - case 18 /* TupleElementTypes */: - case 11 /* ArrayBindingElements */: + case 13 /* ArrayLiteralMembers */: + case 17 /* TupleElementTypes */: + case 10 /* ArrayBindingElements */: return token === 19 /* CloseBracketToken */; - case 15 /* Parameters */: + case 14 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; - case 21 /* JSDocFunctionParameters */: + case 20 /* JSDocFunctionParameters */: return token === 17 /* CloseParenToken */ || token === 51 /* ColonToken */ || token === 15 /* CloseBraceToken */; - case 22 /* JSDocTypeArguments */: + case 21 /* JSDocTypeArguments */: return token === 25 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; - case 24 /* JSDocTupleTypes */: + case 23 /* JSDocTupleTypes */: return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return token === 15 /* CloseBraceToken */; } } @@ -7590,7 +7944,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 24 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -7600,47 +7954,25 @@ var ts; return false; } // Parses a list of elements - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - // test elements only if we are not already in strict mode - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the - // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -7688,7 +8020,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 63 /* ParserGeneratedFlags */; + var nodeContextFlags = node.parserContextFlags & 62 /* ParserGeneratedFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -7707,37 +8039,36 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1 /* ModuleElements */: - return isReusableModuleElement(node); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: return isReusableClassMember(node); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return isReusableSwitchClause(node); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: return isReusableStatement(node); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: return isReusableEnumMember(node); - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isReusableTypeMember(node); - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isReusableVariableDeclaration(node); - case 15 /* Parameters */: + case 14 /* Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 18 /* TupleElementTypes */: + case 17 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -7745,51 +8076,41 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // This is not safe to reuse for the same reason as the 'AssignmentExpression' // cases. i.e. a property assignment may end with an expression, and thus might // have lookahead far beyond it's old node. - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: // This is probably not safe to reuse. There can be speculative parsing with // type names in a heritage clause. There can be generic names in the type // name list, and there can be left hand side expressions (which can have type // arguments.) - case 8 /* HeritageClauseElement */: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - return true; - } - return isReusableStatement(node); + case 7 /* HeritageClauseElement */: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: - case 179 /* SemicolonClassElement */: + case 137 /* Constructor */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 181 /* SemicolonClassElement */: return true; + case 136 /* MethodDeclaration */: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 114 /* ConstructorKeyword */; + return !nameIsConstructor; } } return false; @@ -7797,8 +8118,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return true; } } @@ -7807,49 +8128,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 181 /* VariableStatement */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 183 /* ExpressionStatement */: - case 196 /* ThrowStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 182 /* EmptyStatement */: - case 197 /* TryStatement */: - case 195 /* LabeledStatement */: - case 185 /* DoStatement */: - case 198 /* DebuggerStatement */: + case 203 /* FunctionDeclaration */: + case 183 /* VariableStatement */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 185 /* ExpressionStatement */: + case 198 /* ThrowStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 184 /* EmptyStatement */: + case 199 /* TryStatement */: + case 197 /* LabeledStatement */: + case 187 /* DoStatement */: + case 200 /* DebuggerStatement */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 206 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227 /* EnumMember */; + return node.kind === 229 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140 /* ConstructSignature */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 132 /* PropertySignature */: - case 139 /* CallSignature */: + case 141 /* ConstructSignature */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 133 /* PropertySignature */: + case 140 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199 /* VariableDeclaration */) { + if (node.kind !== 201 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -7870,7 +8200,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130 /* Parameter */) { + if (node.kind !== 131 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -7889,30 +8219,29 @@ var ts; function parsingContextErrors(context) { switch (context) { case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 13 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 14 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 15 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 16 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 18 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 19 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 20 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 21 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 22 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 24 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 23 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; + case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 13 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 14 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 15 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 17 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 18 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 19 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 20 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 21 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 23 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 22 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -7986,7 +8315,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(127 /* QualifiedName */, entity.pos); + var node = createNode(128 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7994,38 +8323,38 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - // Technically a keyword is valid here as all keywords are identifier names. - // However, often we'll encounter this in error situations when the keyword + // Technically a keyword is valid here as all identifiers and keywords are identifier names. + // However, often we'll encounter this in error situations when the identifier or keyword // is actually starting another valid construct. // // So, we check for the following specific case: // // name. - // keyword identifierNameOrKeyword + // identifierOrKeyword identifierNameOrKeyword // // Note: the newlines are important here. For example, if that above code // were rewritten into: // - // name.keyword + // name.identifierOrKeyword // identifierNameOrKeyword // // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.keyword; identifierNameOrKeyword". + // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a - // line terminator after the keyword. - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + // line terminator after the identifier or keyword. + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually - // be an identifier and the error woudl be quite confusing. + // be an identifier and the error would be quite confusing. return createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172 /* TemplateExpression */); + var template = createNode(174 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8038,7 +8367,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178 /* TemplateSpan */); + var span = createNode(180 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -8078,22 +8407,30 @@ var ts; return node; } // TYPES - function parseTypeReference() { - var node = createNode(142 /* TypeReference */); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 /* Identifier */ && token === 117 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143 /* TypePredicate */, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144 /* TypeReference */, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145 /* TypeQuery */); + var node = createNode(147 /* TypeQuery */); parseExpected(97 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129 /* TypeParameter */); + var node = createNode(130 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(79 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8118,7 +8455,7 @@ var ts; } function parseTypeParameters() { if (token === 24 /* LessThanToken */) { - return parseBracketedList(16 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + return parseBracketedList(15 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } } function parseParameterType() { @@ -8139,7 +8476,7 @@ var ts; } } function parseParameter() { - var node = createNode(130 /* Parameter */); + var node = createNode(131 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); @@ -8210,7 +8547,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15 /* Parameters */, parseParameter); + var result = parseDelimitedList(14 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { @@ -8236,7 +8573,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140 /* ConstructSignature */) { + if (kind === 141 /* ConstructSignature */) { parseExpected(88 /* NewKeyword */); } fillSignature(51 /* ColonToken */, false, false, node); @@ -8300,10 +8637,10 @@ var ts; return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141 /* IndexSignature */, fullStart); + var node = createNode(142 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(14 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8313,7 +8650,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(134 /* MethodSignature */, fullStart); + var method = createNode(135 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -8323,7 +8660,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132 /* PropertySignature */, fullStart); + var property = createNode(133 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8365,7 +8702,7 @@ var ts; switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(139 /* CallSignature */); + return parseSignatureMember(140 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -8373,7 +8710,7 @@ var ts; : parsePropertyOrMethodSignature(); case 88 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140 /* ConstructSignature */); + return parseSignatureMember(141 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -8410,14 +8747,14 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(146 /* TypeLiteral */); + var node = createNode(148 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14 /* OpenBraceToken */)) { - members = parseList(5 /* TypeMembers */, false, parseTypeMember); + members = parseList(4 /* TypeMembers */, parseTypeMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -8426,12 +8763,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148 /* TupleType */); - node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(150 /* TupleType */); + node.elementTypes = parseBracketedList(17 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150 /* ParenthesizedType */); + var node = createNode(152 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -8439,7 +8776,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144 /* ConstructorType */) { + if (kind === 146 /* ConstructorType */) { parseExpected(88 /* NewKeyword */); } fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); @@ -8452,13 +8789,13 @@ var ts; function parseNonArrayType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99 /* VoidKeyword */: return parseTokenNode(); case 97 /* TypeOfKeyword */: @@ -8470,16 +8807,16 @@ var ts; case 16 /* OpenParenToken */: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 97 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: @@ -8503,7 +8840,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(147 /* ArrayType */, type.pos); + var node = createNode(149 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -8518,7 +8855,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149 /* UnionType */, type.pos); + var node = createNode(151 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } @@ -8573,10 +8910,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143 /* FunctionType */); + return parseFunctionOrConstructorType(145 /* FunctionType */); } if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(144 /* ConstructorType */); + return parseFunctionOrConstructorType(146 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -8745,11 +9082,6 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - // If we're in strict mode, then 'yield' is a keyword, could only ever start - // a yield expression. - return true; - } // We're in a context where 'yield expr' is not allowed. However, if we can // definitely tell that the user was trying to parse a 'yield expr' and not // just a normal expr that start with a 'yield' identifier, then parse out @@ -8764,7 +9096,7 @@ var ts; // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -8773,7 +9105,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173 /* YieldExpression */); + var node = createNode(175 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -8793,8 +9125,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164 /* ArrowFunction */, identifier.pos); - var parameter = createNode(130 /* Parameter */, identifier.pos); + var node = createNode(166 /* ArrowFunction */, identifier.pos); + var parameter = createNode(131 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8912,7 +9244,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164 /* ArrowFunction */); + var node = createNode(166 /* ArrowFunction */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -8974,7 +9306,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(171 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(173 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8987,7 +9319,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 126 /* OfKeyword */; + return t === 86 /* InKeyword */ || t === 127 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9053,33 +9385,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170 /* BinaryExpression */, left.pos); + var node = createNode(172 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168 /* PrefixUnaryExpression */); + var node = createNode(170 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165 /* DeleteExpression */); + var node = createNode(167 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166 /* TypeOfExpression */); + var node = createNode(168 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167 /* VoidExpression */); + var node = createNode(169 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9109,7 +9441,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(171 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9213,14 +9545,14 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(156 /* PropertyAccessExpression */, expression.pos); + var node = createNode(158 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161 /* TypeAssertionExpression */); + var node = createNode(163 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); parseExpected(25 /* GreaterThanToken */); @@ -9231,7 +9563,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(156 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(158 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -9240,7 +9572,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(157 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(159 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -9256,7 +9588,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(160 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(162 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -9279,7 +9611,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -9287,7 +9619,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -9298,7 +9630,7 @@ var ts; } function parseArgumentList() { parseExpected(16 /* OpenParenToken */); - var result = parseDelimitedList(12 /* ArgumentExpressions */, parseArgumentExpression); + var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); parseExpected(17 /* CloseParenToken */); return result; } @@ -9306,7 +9638,7 @@ var ts; if (!parseOptional(24 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(17 /* TypeArguments */, parseType); + var typeArguments = parseDelimitedList(16 /* TypeArguments */, parseType); if (!parseExpected(25 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -9389,41 +9721,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162 /* ParenthesizedExpression */); + var node = createNode(164 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174 /* SpreadElementExpression */); + var node = createNode(176 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(176 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(178 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154 /* ArrayLiteralExpression */); + var node = createNode(156 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 512 /* MultiLine */; - node.elements = parseDelimitedList(14 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(137 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(138 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(121 /* SetKeyword */)) { - return parseAccessorDeclaration(138 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(122 /* SetKeyword */)) { + return parseAccessorDeclaration(139 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -9446,13 +9778,13 @@ var ts; } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(228 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(227 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51 /* ColonToken */); @@ -9461,12 +9793,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155 /* ObjectLiteralExpression */); + var node = createNode(157 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512 /* MultiLine */; } - node.properties = parseDelimitedList(13 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } @@ -9479,7 +9811,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163 /* FunctionExpression */); + var node = createNode(165 /* FunctionExpression */); parseExpected(83 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -9494,7 +9826,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159 /* NewExpression */); + var node = createNode(161 /* NewExpression */); parseExpected(88 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -9504,10 +9836,10 @@ var ts; return finishNode(node); } // STATEMENTS - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180 /* Block */); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -9524,7 +9856,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -9532,12 +9864,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182 /* EmptyStatement */); + var node = createNode(184 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(184 /* IfStatement */); + var node = createNode(186 /* IfStatement */); parseExpected(84 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9547,7 +9879,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185 /* DoStatement */); + var node = createNode(187 /* DoStatement */); parseExpected(75 /* DoKeyword */); node.statement = parseStatement(); parseExpected(100 /* WhileKeyword */); @@ -9562,7 +9894,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186 /* WhileStatement */); + var node = createNode(188 /* WhileStatement */); parseExpected(100 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9585,21 +9917,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(188 /* ForInStatement */, pos); + var forInStatement = createNode(190 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126 /* OfKeyword */)) { - var forOfStatement = createNode(189 /* ForOfStatement */, pos); + else if (parseOptional(127 /* OfKeyword */)) { + var forOfStatement = createNode(191 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187 /* ForStatement */, pos); + var forStatement = createNode(189 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -9617,7 +9949,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -9625,7 +9957,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192 /* ReturnStatement */); + var node = createNode(194 /* ReturnStatement */); parseExpected(90 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -9634,7 +9966,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193 /* WithStatement */); + var node = createNode(195 /* WithStatement */); parseExpected(101 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9643,32 +9975,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221 /* CaseClause */); + var node = createNode(223 /* CaseClause */); parseExpected(67 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222 /* DefaultClause */); + var node = createNode(224 /* DefaultClause */); parseExpected(73 /* DefaultKeyword */); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194 /* SwitchStatement */); + var node = createNode(196 /* SwitchStatement */); parseExpected(92 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(208 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(210 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); - caseBlock.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -9681,7 +10013,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(196 /* ThrowStatement */); + var node = createNode(198 /* ThrowStatement */); parseExpected(94 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -9689,30 +10021,30 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(197 /* TryStatement */); + var node = createNode(199 /* TryStatement */); parseExpected(96 /* TryKeyword */); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. if (!node.catchClause || token === 81 /* FinallyKeyword */) { parseExpected(81 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224 /* CatchClause */); + var result = createNode(226 /* CatchClause */); parseExpected(68 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198 /* DebuggerStatement */); + var node = createNode(200 /* DebuggerStatement */); parseExpected(72 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -9724,13 +10056,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(195 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(197 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(185 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -9743,7 +10075,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98 /* VarKeyword */: @@ -9752,28 +10088,52 @@ var ts; case 83 /* FunctionKeyword */: case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: - return 1 /* Statement */; + return true; + // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; + // however, an identifier cannot be followed by another identifier on the same line. This is what we + // count on to parse out the respective declarations. For instance, we exploit this to say that + // + // namespace n + // + // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees + // + // namespace + // n + // + // as the identifier 'namespace' on one line followed by the identifier 'n' on another. + // We need to look one token ahead to see if it permissible to try parsing a declaration. + // + // *Note*: 'interface' is actually a strict mode reserved word. So while + // + // "use strict" + // interface + // I {} + // + // could be legal, it would add complexity for very little gain. case 103 /* InterfaceKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: + return nextTokenIsIdentifierOnSameLine(); + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115 /* DeclareKeyword */: nextToken(); - return isIdentifierOrKeyword() ? 1 /* Statement */ : 0 /* None */; - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - nextToken(); - return isIdentifierOrKeyword() || token === 8 /* StringLiteral */ ? 2 /* ModuleElement */ : 0 /* None */; + // ASI takes effect for this modifier. + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85 /* ImportKeyword */: nextToken(); return token === 8 /* StringLiteral */ || token === 35 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword() ? - 2 /* ModuleElement */ : 0 /* None */; + token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); case 78 /* ExportKeyword */: nextToken(); if (token === 53 /* EqualsToken */ || token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */ || token === 73 /* DefaultKeyword */) { - return 2 /* ModuleElement */; + return true; } continue; - case 115 /* DeclareKeyword */: case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: @@ -9781,14 +10141,14 @@ var ts; nextToken(); continue; default: - return 0 /* None */; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52 /* AtToken */: case 22 /* SemicolonToken */: @@ -9814,61 +10174,44 @@ var ts; // however, we say they are here so that we may gracefully parse them and error later. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: - return 1 /* Statement */; + return true; case 70 /* ConstKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115 /* DeclareKeyword */: case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - case 124 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + case 125 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement - return getDeclarationFlags() || 1 /* Statement */; + return true; case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 109 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 /* None */ : 1 /* Statement */); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 /* Statement */ : 0 /* None */; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1 /* Statement */) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3 /* StatementOrModuleElement */) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */); + return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; } function isLetDeclaration() { - // It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line. - // otherwise it needs to be treated like identifier - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1 /* Statement */); - } - function parseModuleElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseSourceElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22 /* SemicolonToken */: return parseEmptyStatement(); case 14 /* OpenBraceToken */: - return parseBlock(false, false); + return parseBlock(false); case 98 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104 /* LetKeyword */: @@ -9889,9 +10232,9 @@ var ts; case 82 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(190 /* ContinueStatement */); + return parseBreakOrContinueStatement(192 /* ContinueStatement */); case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(191 /* BreakStatement */); + return parseBreakOrContinueStatement(193 /* BreakStatement */); case 90 /* ReturnKeyword */: return parseReturnStatement(); case 101 /* WithKeyword */: @@ -9901,7 +10244,7 @@ var ts; case 94 /* ThrowKeyword */: return parseThrowStatement(); case 96 /* TryKeyword */: - // Include the next two for error recovery. + // Include 'catch' and 'finally' for error recovery. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: return parseTryStatement(); @@ -9909,20 +10252,20 @@ var ts; return parseDebuggerStatement(); case 52 /* AtToken */: return parseDeclaration(); - case 70 /* ConstKeyword */: + case 103 /* InterfaceKeyword */: + case 125 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: case 115 /* DeclareKeyword */: + case 70 /* ConstKeyword */: case 77 /* EnumKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 108 /* PublicKeyword */: case 109 /* StaticKeyword */: - case 124 /* TypeKeyword */: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -9944,12 +10287,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -9959,10 +10302,10 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(219 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(221 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -9970,6 +10313,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); @@ -9980,16 +10327,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(176 /* OmittedExpression */); + return createNode(178 /* OmittedExpression */); } - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -10005,16 +10352,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151 /* ObjectBindingPattern */); + var node = createNode(153 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); - node.elements = parseDelimitedList(10 /* ObjectBindingElements */, parseObjectBindingElement); + node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152 /* ArrayBindingPattern */); + var node = createNode(154 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); - node.elements = parseDelimitedList(11 /* ArrayBindingElements */, parseArrayBindingElement); + node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } @@ -10031,7 +10378,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199 /* VariableDeclaration */); + var node = createNode(201 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -10040,7 +10387,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200 /* VariableDeclarationList */); + var node = createNode(202 /* VariableDeclarationList */); switch (token) { case 98 /* VarKeyword */: break; @@ -10063,13 +10410,13 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 126 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); + node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -10078,7 +10425,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181 /* VariableStatement */, fullStart); + var node = createNode(183 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -10086,7 +10433,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201 /* FunctionDeclaration */, fullStart); + var node = createNode(203 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83 /* FunctionKeyword */); @@ -10097,7 +10444,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136 /* Constructor */, pos); + var node = createNode(137 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114 /* ConstructorKeyword */); @@ -10106,7 +10453,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135 /* MethodDeclaration */, fullStart); + var method = createNode(136 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10117,7 +10464,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133 /* PropertyDeclaration */, fullStart); + var property = createNode(134 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -10209,7 +10556,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 121 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 122 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -10243,7 +10590,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131 /* Decorator */, decoratorStart); + var decorator = createNode(132 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -10276,7 +10623,7 @@ var ts; } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(179 /* SemicolonClassElement */); + var result = createNode(181 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -10302,7 +10649,7 @@ var ts; token === 18 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. var name_6 = createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); @@ -10314,15 +10661,12 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 175 /* ClassExpression */); + /*modifiers*/ undefined, 177 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -10342,9 +10686,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -10358,23 +10700,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19 /* HeritageClauses */, false, parseHeritageClause); + return parseList(18 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(223 /* HeritageClause */); + var node = createNode(225 /* HeritageClause */); node.token = token; nextToken(); - node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177 /* ExpressionWithTypeArguments */); + var node = createNode(179 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } @@ -10382,10 +10724,10 @@ var ts; return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; } function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassElement); + return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* InterfaceDeclaration */, fullStart); + var node = createNode(205 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103 /* InterfaceKeyword */); @@ -10396,11 +10738,12 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204 /* TypeAliasDeclaration */, fullStart); + var node = createNode(206 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124 /* TypeKeyword */); + parseExpected(125 /* TypeKeyword */); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53 /* EqualsToken */); node.type = parseType(); parseSemicolon(); @@ -10411,19 +10754,19 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(227 /* EnumMember */, scanner.getStartPos()); + var node = createNode(229 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* EnumDeclaration */, fullStart); + var node = createNode(207 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(14 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); + node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -10432,9 +10775,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(209 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { - node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -10443,7 +10786,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -10454,7 +10797,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -10463,11 +10806,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118 /* NamespaceKeyword */)) { + if (parseOptional(119 /* NamespaceKeyword */)) { flags |= 32768 /* Namespace */; } else { - parseExpected(117 /* ModuleKeyword */); + parseExpected(118 /* ModuleKeyword */); if (token === 8 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -10475,7 +10818,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 /* RequireKeyword */ && + return token === 120 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -10484,7 +10827,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 125 /* FromKeyword */; + token === 126 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85 /* ImportKeyword */); @@ -10492,11 +10835,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 125 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 126 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(209 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(211 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -10507,7 +10850,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(210 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(212 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -10517,7 +10860,7 @@ var ts; token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -10530,7 +10873,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211 /* ImportClause */, fullStart); + var importClause = createNode(213 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -10540,7 +10883,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(213 /* NamedImports */); + importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(215 /* NamedImports */); } return finishNode(importClause); } @@ -10550,8 +10893,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220 /* ExternalModuleReference */); - parseExpected(119 /* RequireKeyword */); + var node = createNode(222 /* ExternalModuleReference */); + parseExpected(120 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -10572,7 +10915,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(212 /* NamespaceImport */); + var namespaceImport = createNode(214 /* NamespaceImport */); parseExpected(35 /* AsteriskToken */); parseExpected(111 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -10587,14 +10930,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 213 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(19 /* ImportOrExportSpecifiers */, kind === 215 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218 /* ExportSpecifier */); + return parseImportOrExportSpecifier(220 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214 /* ImportSpecifier */); + return parseImportOrExportSpecifier(216 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -10619,23 +10962,23 @@ var ts; else { node.name = identifierName; } - if (kind === 214 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 216 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ExportDeclaration */, fullStart); + var node = createNode(218 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217 /* NamedExports */); - if (parseOptional(125 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(219 /* NamedExports */); + if (parseOptional(126 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -10643,7 +10986,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215 /* ExportAssignment */, fullStart); + var node = createNode(217 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53 /* EqualsToken */)) { @@ -10711,15 +11054,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */ - || node.kind === 210 /* ImportDeclaration */ - || node.kind === 215 /* ExportAssignment */ - || node.kind === 216 /* ExportDeclaration */ + || node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */ + || node.kind === 212 /* ImportDeclaration */ + || node.kind === 217 /* ExportAssignment */ + || node.kind === 218 /* ExportDeclaration */ ? node : undefined; }); @@ -10727,31 +11070,30 @@ var ts; var ParsingContext; (function (ParsingContext) { ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; - ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 8] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 10] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 11] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 12] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 13] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 14] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 15] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 16] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 17] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 18] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 19] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 20] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 21] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 22] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 23] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 24] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 25] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 13] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 14] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 15] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 16] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 17] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 18] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 19] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 20] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 21] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 22] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 23] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -10793,7 +11135,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(229 /* JSDocTypeExpression */); + var result = createNode(231 /* JSDocTypeExpression */); parseExpected(14 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(15 /* CloseBraceToken */); @@ -10804,12 +11146,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44 /* BarToken */) { - var unionType = createNode(233 /* JSDocUnionType */, type.pos); + var unionType = createNode(235 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53 /* EqualsToken */) { - var optionalType = createNode(240 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -10820,20 +11162,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(232 /* JSDocArrayType */, type.pos); + var arrayType = createNode(234 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 50 /* QuestionToken */) { - var nullableType = createNode(235 /* JSDocNullableType */, type.pos); + var nullableType = createNode(237 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46 /* ExclamationToken */) { - var nonNullableType = createNode(236 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(238 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -10867,40 +11209,40 @@ var ts; case 93 /* ThisKeyword */: return parseJSDocThisType(); case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244 /* JSDocThisType */); + var result = createNode(246 /* JSDocThisType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243 /* JSDocConstructorType */); + var result = createNode(245 /* JSDocConstructorType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242 /* JSDocVariadicType */); + var result = createNode(244 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241 /* JSDocFunctionType */); + var result = createNode(243 /* JSDocFunctionType */); nextToken(); parseExpected(16 /* OpenParenToken */); - result.parameters = parseDelimitedList(21 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(20 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17 /* CloseParenToken */); if (token === 51 /* ColonToken */) { @@ -10910,18 +11252,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130 /* Parameter */); + var parameter = createNode(131 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240 /* JSDocOptionalType */, type.pos); + var result = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239 /* JSDocTypeReference */); + var result = createNode(241 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(20 /* DotToken */)) { if (token === 24 /* LessThanToken */) { @@ -10937,7 +11279,7 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(22 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(21 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25 /* GreaterThanToken */); @@ -10951,21 +11293,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127 /* QualifiedName */, left.pos); + var result = createNode(128 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237 /* JSDocRecordType */); + var result = createNode(239 /* JSDocRecordType */); nextToken(); - result.members = parseDelimitedList(23 /* JSDocRecordMembers */, parseJSDocRecordMember); + result.members = parseDelimitedList(22 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238 /* JSDocRecordMember */); + var result = createNode(240 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 51 /* ColonToken */) { nextToken(); @@ -10974,15 +11316,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236 /* JSDocNonNullableType */); + var result = createNode(238 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234 /* JSDocTupleType */); + var result = createNode(236 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(24 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(23 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19 /* CloseBracketToken */); return finishNode(result); @@ -10994,7 +11336,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233 /* JSDocUnionType */); + var result = createNode(235 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17 /* CloseParenToken */); @@ -11012,7 +11354,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230 /* JSDocAllType */); + var result = createNode(232 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11035,11 +11377,11 @@ var ts; token === 25 /* GreaterThanToken */ || token === 53 /* EqualsToken */ || token === 44 /* BarToken */) { - var result = createNode(231 /* JSDocUnknownType */, pos); + var result = createNode(233 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(235 /* JSDocNullableType */, pos); + var result = createNode(237 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -11127,7 +11469,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245 /* JSDocComment */, start); + var result = createNode(247 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -11165,7 +11507,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246 /* JSDocTag */, atToken.pos); + var result = createNode(248 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -11217,7 +11559,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247 /* JSDocParameterTag */, atToken.pos); + var result = createNode(249 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -11227,27 +11569,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248 /* JSDocReturnTag */, atToken.pos); + var result = createNode(250 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249 /* JSDocTypeTag */, atToken.pos); + var result = createNode(251 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -11260,7 +11602,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129 /* TypeParameter */, name_7.pos); + var typeParameter = createNode(130 /* TypeParameter */, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -11271,7 +11613,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(252 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -11857,8 +12199,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -11874,10 +12216,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -11909,6 +12248,11 @@ var ts; flags: 2097152 /* ESSymbol */ } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -12051,10 +12395,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228 /* SourceFile */); + return ts.getAncestor(node, 230 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 228 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 230 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12111,40 +12455,54 @@ var ts; } } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 206 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { - if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 218 /* ExportSpecifier */)) { - break loop; + case 208 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 /* SourceFile */ || + (location.kind === 208 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExports[name], 220 /* ExportSpecifier */)) { + break; } - result = undefined; - } - else if (location.kind === 228 /* SourceFile */ || - (location.kind === 206 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { + break loop; + } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === 202 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -12154,8 +12512,9 @@ var ts; } } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 205 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -12166,6 +12525,13 @@ var ts; } break loop; } + if (location.kind === 177 /* ClassExpression */ && meaning & 32 /* Class */) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } break; // It is not legal to reference a class's own type parameters from a computed property name that // belongs to the class. For example: @@ -12175,9 +12541,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (grandparent.kind === 202 /* ClassDeclaration */ || grandparent.kind === 203 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 205 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -12185,19 +12551,19 @@ var ts; } } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -12210,16 +12576,7 @@ var ts; } } break; - case 175 /* ClassExpression */: - if (meaning & 32 /* Class */) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -12228,7 +12585,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 130 /* Parameter */) { + if (location.parent && location.parent.kind === 131 /* Parameter */) { location = location.parent; } // @@ -12284,16 +12641,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 199 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 201 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 187 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 183 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 189 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 188 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 190 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -12320,10 +12677,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 210 /* ImportDeclaration */) { + while (node && node.kind !== 212 /* ImportDeclaration */) { node = node.parent; } return node; @@ -12333,7 +12690,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 222 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12440,17 +12797,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return getTargetOfImportClause(node); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 214 /* ImportSpecifier */: + case 216 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 218 /* ExportSpecifier */: + case 220 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -12495,11 +12852,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215 /* ExportAssignment */) { + if (node.kind === 217 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 218 /* ExportSpecifier */) { + else if (node.kind === 220 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -12512,7 +12869,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 211 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -12525,13 +12882,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 127 /* QualifiedName */) { + if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 128 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 209 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 211 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -12551,9 +12908,9 @@ var ts; return undefined; } } - else if (name.kind === 127 /* QualifiedName */ || name.kind === 156 /* PropertyAccessExpression */) { - var left = name.kind === 127 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 127 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 128 /* QualifiedName */ || name.kind === 158 /* PropertyAccessExpression */) { + var left = name.kind === 128 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 128 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12714,7 +13071,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -12784,17 +13141,17 @@ var ts; } } switch (location_1.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12943,8 +13300,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 228 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 208 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 230 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12980,12 +13337,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 145 /* TypeQuery */) { + if (entityName.parent.kind === 147 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 127 /* QualifiedName */ || entityName.kind === 156 /* PropertyAccessExpression */ || - entityName.parent.kind === 209 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 128 /* QualifiedName */ || entityName.kind === 158 /* PropertyAccessExpression */ || + entityName.parent.kind === 211 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13019,6 +13376,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -13033,10 +13397,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150 /* ParenthesizedType */) { + while (node.kind === 152 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 206 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -13045,19 +13409,28 @@ var ts; // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. var _displayBuilder; function getSymbolDisplayBuilder() { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 177 /* ClassExpression */: + return "(Anonymous class)"; + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + return "(Anonymous function)"; + } + } + return symbol.name; + } /** * Writes only the name of the symbol out to the writer. Uses the original source text * for the name of the symbol if it is available to match how the user inputted the name. */ function appendSymbolNameOnly(symbol, writer) { - if (symbol.declarations && symbol.declarations.length > 0) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - writer.writeSymbol(ts.declarationNameToString(declaration.name), symbol); - return; - } - } - writer.writeSymbol(symbol.name, symbol); + writer.writeSymbol(getNameOfSymbol(symbol), symbol); } /** * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope @@ -13286,7 +13659,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 /* SourceFile */ || declaration.parent.kind === 207 /* ModuleBlock */; + return declaration.parent.kind === 230 /* SourceFile */ || declaration.parent.kind === 209 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -13364,7 +13737,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 122 /* StringKeyword */); + writeKeyword(writer, 123 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13378,7 +13751,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 120 /* NumberKeyword */); + writeKeyword(writer, 121 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13421,7 +13794,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -13525,12 +13898,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 228 /* SourceFile */) { + else if (node.kind === 230 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -13579,69 +13952,69 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153 /* BindingElement */: + case 155 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 206 /* ModuleDeclaration */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 201 /* FunctionDeclaration */: - case 205 /* EnumDeclaration */: - case 209 /* ImportEqualsDeclaration */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 203 /* FunctionDeclaration */: + case 207 /* EnumDeclaration */: + case 211 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 209 /* ImportEqualsDeclaration */ && parent_4.kind !== 228 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 /* ImportEqualsDeclaration */ && parent_4.kind !== 230 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 136 /* Constructor */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: - case 130 /* Parameter */: - case 207 /* ModuleBlock */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: - case 142 /* TypeReference */: - case 147 /* ArrayType */: - case 148 /* TupleType */: - case 149 /* UnionType */: - case 150 /* ParenthesizedType */: + case 137 /* Constructor */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: + case 131 /* Parameter */: + case 209 /* ModuleBlock */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: + case 144 /* TypeReference */: + case 149 /* ArrayType */: + case 150 /* TupleType */: + case 151 /* UnionType */: + case 152 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: return false; // Type parameters are always visible - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: // Source file is always visible - case 228 /* SourceFile */: + case 230 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -13657,10 +14030,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 217 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218 /* ExportSpecifier */) { + else if (node.parent.kind === 220 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -13718,7 +14091,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 199 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 201 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -13754,7 +14127,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_9 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -13801,10 +14174,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 188 /* ForInStatement */) { + if (declaration.parent.parent.kind === 190 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 191 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -13818,11 +14191,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 138 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137 /* GetAccessor */); + if (func.kind === 139 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13838,7 +14211,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 226 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 228 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -13873,7 +14246,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -13896,7 +14269,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 /* ObjectBindingPattern */ + return pattern.kind === 153 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -13918,7 +14291,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 225 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 227 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -13930,7 +14303,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13945,11 +14318,11 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224 /* CatchClause */) { + if (declaration.parent.kind === 226 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 215 /* ExportAssignment */) { + if (declaration.kind === 217 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -13980,7 +14353,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13996,8 +14369,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 138 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 139 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -14026,7 +14399,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -14126,9 +14499,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 /* ClassDeclaration */ || node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || node.kind === 135 /* MethodDeclaration */ || - node.kind === 164 /* ArrowFunction */) { + if (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */ || + node.kind === 203 /* FunctionDeclaration */ || node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */ || node.kind === 166 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14138,15 +14511,17 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 /* Class */ ? 202 /* ClassDeclaration */ : 203 /* InterfaceDeclaration */; - return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); + return appendOuterTypeParameters(undefined, declaration); } - // The local type parameters are the combined set of type parameters from all declarations of the class or interface. - function getLocalTypeParametersOfClassOrInterface(symbol) { + // The local type parameters are the combined set of type parameters from all declarations of the class, + // interface, or type alias. + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 204 /* ClassDeclaration */ || + node.kind === 177 /* ClassExpression */ || node.kind === 206 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14158,56 +14533,122 @@ var ts; // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus // its locally declared type parameters. function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // unknownType if an error occurred during resolution of the extends expression, + // nullType if the extends expression is the null value, or + // an object type with at least one construct signature. + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128 /* ObjectType */) { + // Resolving the members of a class requires us to resolve the base class of that class. + // We force resolution here such that we catch circularities now. + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32 /* Class */) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64 /* Interface */) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202 /* ClassDeclaration */); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024 /* Class */) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128 /* ObjectType */)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); @@ -14227,7 +14668,7 @@ var ts; var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -14249,9 +14690,18 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 206 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + // Initialize the instantiation cache for generic type aliases. The declared type corresponds to + // an instantiation of the type alias with the type parameters supplied as type arguments. + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -14273,7 +14723,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14388,34 +14838,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1 /* Construct */); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 /* Reference */ ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -14521,10 +14979,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128 /* ObjectType */) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -14745,7 +15203,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -14767,24 +15225,33 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143 /* TypePredicate */) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 137 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138 /* SetAccessor */); + if (declaration.kind === 138 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -14795,19 +15262,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -14884,7 +15351,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 /* Constructor */ || signature.declaration.kind === 140 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 137 /* Constructor */ || signature.declaration.kind === 141 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 131072 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -14898,7 +15365,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 120 /* NumberKeyword */ : 122 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 121 /* NumberKeyword */ : 123 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -14928,13 +15395,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -14987,13 +15454,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 144 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -15005,7 +15472,7 @@ var ts; // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -15019,62 +15486,82 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - // We don't currently support heritage clauses with complex expressions in them. - // For these cases, we just set the type to be the unknownType. - if (node.kind !== 177 /* ExpressionWithTypeArguments */ || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 /* TypeReference */ - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056 /* Type */); - if (symbol) { - if ((symbol.flags & 262144 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // Implementation: such type references are resolved to 'unknown' type that usually denotes error - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + // Get type from reference to class or interface + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; - } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */) && type.flags & 4096 /* Reference */) { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - // When no type arguments are expected we already have the right type because all outer type parameters - // have themselves as default type arguments. - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), expectedTypeArgCount); - return undefined; - } + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include + // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the + // declared type. Instantiations are cached using the type identities of the type arguments as the key. + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // Implementation: such type references are resolved to 'unknown' type that usually denotes error + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 144 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the + // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -15082,7 +15569,7 @@ var ts; // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -15092,9 +15579,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: return declaration; } } @@ -15129,6 +15616,15 @@ var ts; function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + /** + * Creates a TypeReference for a generic `TypedPropertyDescriptor`. + */ + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -15307,40 +15803,42 @@ var ts; switch (node.kind) { case 112 /* AnyKeyword */: return anyType; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: return stringType; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return numberType; case 113 /* BooleanKeyword */: return booleanType; - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return esSymbolType; case 99 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 142 /* TypeReference */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177 /* ExpressionWithTypeArguments */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145 /* TypeQuery */: + case 144 /* TypeReference */: + return getTypeFromTypeReference(node); + case 143 /* TypePredicate */: + return booleanType; + case 179 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReference(node); + case 147 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15430,11 +15928,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -15499,27 +16005,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return node.operatorToken.kind === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -15527,14 +16033,14 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } @@ -15542,9 +16048,6 @@ var ts; return type; } // TYPE CHECKING - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -15560,8 +16063,8 @@ var ts; function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source, target, errorNode, headMessage) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); @@ -15821,9 +16324,9 @@ var ts; maybeStack[depth][id] = 1 /* Succeeded */; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -15859,27 +16362,6 @@ var ts; } return result; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -16060,6 +16542,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0 /* False */; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -16150,6 +16659,27 @@ var ts; return 0 /* False */; } } + // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case + // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. + // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at + // some level beyond that. + function isDeeplyNestedGeneric(type, stack, depth) { + // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) + if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; } @@ -16356,22 +16886,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130 /* Parameter */: + case 131 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16444,20 +16974,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 /* Reference */ && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -16527,22 +17043,26 @@ var ts; else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; } } function inferFromProperties(source, target) { @@ -16567,7 +17087,17 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + // Return types from type predicates are treated as booleans. In order to infer types + // from type predicates we would need to infer using the type within the type predicate + // (i.e. 'Foo' from 'x is Foo'). + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -16640,10 +17170,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return true; case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: node = node.parent; continue; default: @@ -16691,7 +17221,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { var n = node.left; - while (n.kind === 162 /* ParenthesizedExpression */) { + while (n.kind === 164 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -16708,46 +17238,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 168 /* PrefixUnaryExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 169 /* PostfixUnaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 170 /* PrefixUnaryExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 171 /* PostfixUnaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -16800,19 +17330,19 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184 /* IfStatement */: + case 186 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { @@ -16823,14 +17353,14 @@ var ts; } } break; - case 228 /* SourceFile */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: + case 230 /* SourceFile */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -16847,7 +17377,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 166 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 168 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; @@ -16923,7 +17453,7 @@ var ts; var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - // Target type is type of the protoype property + // Target type is type of the prototype property var prototypePropertyType = getTypeOfSymbol(prototypeProperty); if (!isTypeAny(prototypePropertyType)) { targetType = prototypePropertyType; @@ -16943,14 +17473,36 @@ var ts; } } if (targetType) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (originalType.flags & 16384 /* Union */) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1 /* Any */) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } @@ -16958,9 +17510,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -16975,7 +17529,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -16992,7 +17546,7 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -17016,7 +17570,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 224 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 226 /* CatchClause */) { return; } // - check if binding is used in some function @@ -17025,12 +17579,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 200 /* VariableDeclarationList */) { + while (container.kind !== 202 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 181 /* VariableStatement */) { + if (container.kind === 183 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -17049,9 +17603,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 133 /* PropertyDeclaration */ || container.kind === 136 /* Constructor */) { + if (container.kind === 134 /* PropertyDeclaration */ || container.kind === 137 /* Constructor */) { + var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -17064,64 +17618,61 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 164 /* ArrowFunction */) { + if (container.kind === 166 /* ArrowFunction */) { container = ts.getThisContainer(container, false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 136 /* Constructor */: + case 137 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; - if (classNode) { - var symbol = getSymbolOfNode(classNode); + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130 /* Parameter */) { + if (n.kind === 131 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -17131,7 +17682,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 136 /* Constructor */; + canUseSuperExpression = container.kind === 137 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -17140,28 +17691,28 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 164 /* ArrowFunction */) { + while (container && container.kind === 166 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === 202 /* ClassDeclaration */) { + if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */ || - container.kind === 133 /* PropertyDeclaration */ || - container.kind === 132 /* PropertySignature */ || - container.kind === 136 /* Constructor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */ || + container.kind === 134 /* PropertyDeclaration */ || + container.kind === 133 /* PropertySignature */ || + container.kind === 137 /* Constructor */; } } } @@ -17169,13 +17720,13 @@ var ts; var returnType; if ((container.flags & 128 /* Static */) || isCallExpression) { getNodeLinks(node).flags |= 32 /* SuperStatic */; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16 /* SuperInstance */; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; @@ -17189,7 +17740,7 @@ var ts; return returnType; } } - if (container && container.kind === 128 /* ComputedPropertyName */) { + if (container && container.kind === 129 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -17234,7 +17785,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17269,8 +17820,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 136 /* Constructor */ || - functionDecl.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138 /* SetAccessor */))) { + functionDecl.kind === 137 /* Constructor */ || + functionDecl.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -17292,7 +17843,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160 /* TaggedTemplateExpression */) { + if (template.parent.kind === 162 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17423,34 +17974,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 155 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 164 /* ArrowFunction */: - case 192 /* ReturnStatement */: + case 166 /* ArrowFunction */: + case 194 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 178 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 172 /* TemplateExpression */); + case 180 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 174 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return getContextualType(parent); } return undefined; @@ -17467,7 +18018,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 /* FunctionExpression */ || node.kind === 164 /* ArrowFunction */; + return node.kind === 165 /* FunctionExpression */ || node.kind === 166 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -17481,7 +18032,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -17537,13 +18088,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 172 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 225 /* PropertyAssignment */) { + if (parent.kind === 227 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154 /* ArrayLiteralExpression */) { + if (parent.kind === 156 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -17568,7 +18119,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 176 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -17592,7 +18143,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 176 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -17603,7 +18154,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -17662,18 +18213,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 /* PropertyAssignment */ || - memberDecl.kind === 226 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 227 /* PropertyAssignment */ || + memberDecl.kind === 228 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225 /* PropertyAssignment */) { + if (memberDecl.kind === 227 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135 /* MethodDeclaration */) { + else if (memberDecl.kind === 136 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 228 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -17693,7 +18244,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 137 /* GetAccessor */ || memberDecl.kind === 138 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 138 /* GetAccessor */ || memberDecl.kind === 139 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -17732,7 +18283,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 134 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -17745,7 +18296,7 @@ var ts; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -17781,7 +18332,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -17806,7 +18357,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -17816,14 +18367,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 /* PropertyAccessExpression */ + var left = node.kind === 158 /* PropertyAccessExpression */ ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { return false; } else { @@ -17839,7 +18390,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -17968,10 +18519,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else { + else if (node.kind !== 132 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18036,7 +18587,8 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174 /* SpreadElementExpression */) { + var arg = args[i]; + if (arg && arg.kind === 176 /* SpreadElementExpression */) { return i; } } @@ -18046,13 +18598,15 @@ var ts; var adjustedArgCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 160 /* TaggedTemplateExpression */) { + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 162 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172 /* TemplateExpression */) { + if (tagExpression.template.kind === 174 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -18069,11 +18623,16 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } + else if (node.kind === 132 /* Decorator */) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 159 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 161 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -18081,6 +18640,7 @@ var ts; // If we are missing the close paren, the call is incomplete. callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); } // If the user supplied type arguments, but the number of type arguments does not match // the declared number of type parameters, the call has an incorrect arity. @@ -18091,7 +18651,6 @@ var ts; } // If spread arguments are present, check that they correspond to a rest parameter. If so, no // further checking is necessary. - var spreadArgIndex = getSpreadArgumentIndex(args); if (spreadArgIndex >= 0) { return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1; } @@ -18123,7 +18682,7 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument, context) { + function inferTypeArguments(node, signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; var inferenceMapper = createInferenceMapper(context); // Clear out all the inference results from the last time inferTypeArguments was called on this context @@ -18148,15 +18707,16 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. + if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); - var argType = void 0; - if (i === 0 && args[i].parent.kind === 160 /* TaggedTemplateExpression */) { - argType = globalTemplateStringsArrayType; - } - else { + var argType = getEffectiveArgumentType(node, i, arg); + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; @@ -18168,8 +18728,10 @@ var ts; // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) + // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. + // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { - for (var i = 0; i < args.length; i++) { + for (var i = 0; i < argCount; i++) { // No need to check for omitted args and template expressions, their exlusion value is always undefined if (excludeArgument[i] === false) { var arg = args[i]; @@ -18180,7 +18742,7 @@ var ts; } getInferredTypes(context); } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; for (var i = 0; i < typeParameters.length; i++) { @@ -18191,27 +18753,38 @@ var ts; if (typeArgumentsAreAssignable /* so far */) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); } } } return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. + if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); - // A tagged template expression provides a special first argument, and string literals get string literal types - // unless we're reporting errors - var argType = i === 0 && node.kind === 160 /* TaggedTemplateExpression */ - ? globalTemplateStringsArrayType - : arg.kind === 8 /* StringLiteral */ && !reportErrors + var argType = getEffectiveArgumentType(node, i, arg); + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { + argType = arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } // Use argument expression as error location when reporting errors - if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } } @@ -18223,50 +18796,277 @@ var ts; * * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution - * expressions, where the first element of the list is the template for error reporting purposes. + * expressions, where the first element of the list is `undefined`. + * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types + * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { var template = node.template; - args = [template]; - if (template.kind === 172 /* TemplateExpression */) { + args = [undefined]; + if (template.kind === 174 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } + else if (node.kind === 132 /* Decorator */) { + // For a decorator, we return undefined as we will determine + // the number and types of arguments for a decorator using + // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. + return undefined; + } else { args = node.arguments || emptyArray; } return args; } /** - * In a 'super' call, type arguments are not provided within the CallExpression node itself. - * Instead, they must be fetched from the class declaration's base type node. - * - * If 'node' is a 'super' call (e.g. super(...), new super(...)), then we attempt to fetch - * the type arguments off the containing class's first heritage clause (if one exists). Note that if - * type arguments are supplied on the 'super' call, they are ignored (though this is syntactically incorrect). - * - * In all other cases, the call's explicit type arguments are returned. - */ - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91 /* SuperKeyword */) { - var containingClass = ts.getAncestor(callExpression, 202 /* ClassDeclaration */); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 132 /* Decorator */) { + switch (node.parent.kind) { + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) + return 1; + case 134 /* PropertyDeclaration */: + // A property declaration decorator will have two arguments (see + // `PropertyDecorator` in core.d.ts) + return 2; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + // A method or accessor declaration decorator will have two or three arguments (see + // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If the method decorator signature only accepts a target and a key, we will only + // type check those arguments. + return signature.parameters.length >= 3 ? 3 : 2; + case 131 /* Parameter */: + // A parameter declaration decorator will have three arguments (see + // `ParameterDecorator` in core.d.ts) + return 3; + } } else { - // Ordinary case - simple function invocation. - return callExpression.typeArguments; + return args.length; } } - function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160 /* TaggedTemplateExpression */; + /** + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ + function getEffectiveDecoratorFirstArgumentType(node) { + // The first argument to a decorator is its `target`. + switch (node.kind) { + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // 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 131 /* Parameter */: + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. + node = node.parent; + if (node.kind === 137 /* Constructor */) { + var classSymbol_1 = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol_1); + } + // fall-through + case 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* 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: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ + function getEffectiveDecoratorSecondArgumentType(node) { + // The second argument to a decorator is its `propertyKey` + switch (node.kind) { + case 204 /* ClassDeclaration */: + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + case 131 /* Parameter */: + node = node.parent; + if (node.kind === 137 /* 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 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* 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 + // be either string or symbol. + var element = node; + switch (element.name.kind) { + case 65 /* Identifier */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + return getStringLiteralType(element.name); + case 129 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 2097152 /* ESSymbol */)) { + return nameType; + } + else { + return stringType; + } + default: + 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. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ + 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 204 /* ClassDeclaration */: + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + case 131 /* Parameter */: + // The `parameterIndex` for a parameter decorator is always a number + return numberType; + case 134 /* PropertyDeclaration */: + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` + // 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. + */ + function getEffectiveDecoratorArgumentType(node, argIndex) { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + /** + * Gets the effective argument type for an argument in a call expression. + */ + function getEffectiveArgumentType(node, argIndex, arg) { + // Decorators provide special arguments, a tagged template expression provides + // a special first argument, and string literals get string literal types + // unless we're reporting errors + if (node.kind === 132 /* Decorator */) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + return globalTemplateStringsArrayType; + } + // This is not a synthetic argument, so we return 'undefined' + // to signal that the caller needs to check the argument. + return undefined; + } + /** + * Gets the effective argument expression for an argument in a call expression. + */ + function getEffectiveArgument(node, args, argIndex) { + // For a decorator or the first argument of a tagged template expression we return undefined. + if (node.kind === 132 /* Decorator */ || + (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */)) { + return undefined; + } + return args[argIndex]; + } + /** + * Gets the error node to use when reporting errors for an effective argument. + */ + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 132 /* Decorator */) { + // For a decorator, we use the expression of the decorator for error reporting. + return node.expression; + } + else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 162 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 132 /* Decorator */; var typeArguments; - if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 91 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); @@ -18276,7 +19076,7 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -18291,13 +19091,20 @@ var ts; // // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. + // + // For a decorator, no arguments are susceptible to contextual typing due to the fact + // decorators are applied to a declaration by the emitter, and not to an expression. var excludeArgument; - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); + if (!isDecorator) { + // We do not need to call `getEffectiveArgumentCount` here as it only + // applies when calculating the number of arguments for a decorator. + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; } - excludeArgument[i] = true; } } // The following variables are captured and modified by calls to chooseOverload. @@ -18361,19 +19168,22 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } // No signature was applicable. We have already reported the errors for the invalid signature. // If this is a type resolution session, e.g. Language Service, try to get better information that anySignature. @@ -18389,6 +19199,14 @@ var ts; } } return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } function chooseOverload(candidates, relation) { for (var _i = 0; _i < candidates.length; _i++) { var originalCandidate = candidates[_i]; @@ -18409,7 +19227,7 @@ var ts; typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } @@ -18456,7 +19274,11 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -18568,6 +19390,47 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray); } + /** + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 131 /* Parameter */: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 134 /* PropertyDeclaration */: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + /** + * Resolves a decorator as if it were a call expression. + */ + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } // candidatesOutArray is passed by signature help in the language service, and collectCandidates // must fill it up with the appropriate candidate signatures function getResolvedSignature(node, candidatesOutArray) { @@ -18578,15 +19441,18 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158 /* CallExpression */) { + if (node.kind === 160 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159 /* NewExpression */) { + else if (node.kind === 161 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 162 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } + else if (node.kind === 132 /* Decorator */) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } else { ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); } @@ -18600,12 +19466,12 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { return voidType; } - if (node.kind === 159 /* NewExpression */) { + if (node.kind === 161 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 /* Constructor */ && - declaration.kind !== 140 /* ConstructSignature */ && - declaration.kind !== 144 /* ConstructorType */) { + declaration.kind !== 137 /* Constructor */ && + declaration.kind !== 141 /* ConstructSignature */ && + declaration.kind !== 146 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -18653,7 +19519,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180 /* Block */) { + if (func.body.kind !== 182 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -18733,7 +19599,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 198 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -18748,7 +19614,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182 /* Block */) { return; } var bodyBlock = func.body; @@ -18766,11 +19632,11 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163 /* FunctionExpression */) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165 /* FunctionExpression */) { + checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -18801,14 +19667,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -18821,7 +19687,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180 /* Block */) { + if (node.body.kind === 182 /* Block */) { checkSourceElement(node.body); } else { @@ -18829,7 +19695,7 @@ var ts; if (node.type) { checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); } - checkFunctionExpressionBodies(node.body); + checkFunctionAndClassExpressionBodies(node.body); } } } @@ -18863,17 +19729,17 @@ var ts; // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -18882,11 +19748,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; } - case 157 /* ElementAccessExpression */: { + case 159 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { @@ -18896,7 +19762,7 @@ var ts; } return false; } - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -18913,13 +19779,7 @@ var ts; return true; } function checkDeleteExpression(node) { - // Grammar checking - if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 65 /* Identifier */) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -18931,13 +19791,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator - if ((node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33 /* PlusToken */: @@ -18961,11 +19814,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -19047,7 +19895,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_12 = p.name; var type = isTypeAny(sourceType) @@ -19076,8 +19924,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19102,7 +19950,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 172 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19115,14 +19963,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154 /* ArrayLiteralExpression */) { + if (target.kind === 156 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19135,14 +19983,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - // Grammar checking - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { + if (operator === 53 /* EqualsToken */ && (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -19317,7 +20159,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 /* ClassDeclaration */ || current.kind === 175 /* ClassExpression */) { + else if (ts.isClassLike(current)) { return true; } current = parent; @@ -19393,7 +20235,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -19404,7 +20246,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -19425,10 +20267,6 @@ var ts; } return type; } - function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in @@ -19436,9 +20274,9 @@ var ts; // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpressionOrQualifiedName(node, contextualMapper) { + function checkExpression(node, contextualMapper) { var type; - if (node.kind == 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -19450,9 +20288,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -19479,61 +20317,60 @@ var ts; return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return checkCallExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return checkClassExpression(node); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return checkDeleteExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return checkVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return undefinedType; - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return checkYieldExpression(node); } return unknownType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); @@ -19550,15 +20387,13 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -19575,33 +20410,107 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 /* MethodDeclaration */ || - node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */; + return node.kind === 136 /* MethodDeclaration */ || + node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 /* Identifier */ && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166 /* ArrowFunction */: + case 140 /* CallSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 145 /* FunctionType */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 /* FunctionType */ || node.kind === 201 /* FunctionDeclaration */ || node.kind === 144 /* ConstructorType */ || - node.kind === 139 /* CallSignature */ || node.kind === 136 /* Constructor */ || - node.kind === 140 /* ConstructSignature */) { + else if (node.kind === 145 /* FunctionType */ || node.kind === 203 /* FunctionDeclaration */ || node.kind === 146 /* ConstructorType */ || + node.kind === 140 /* CallSignature */ || node.kind === 137 /* Constructor */ || + node.kind === 141 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143 /* TypePredicate */) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 /* ObjectBindingPattern */ || + param.name.kind === 154 /* ArrayBindingPattern */) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 /* Identifier */ && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 /* ArrayBindingPattern */ || + element.name.kind === 153 /* ObjectBindingPattern */) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -19629,7 +20538,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203 /* InterfaceDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -19649,7 +20558,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -19657,7 +20566,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -19701,17 +20610,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 160 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 155 /* ObjectLiteralExpression */: return false; + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -19719,12 +20628,12 @@ var ts; if (n.kind === 93 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 /* FunctionExpression */ && n.kind !== 201 /* FunctionDeclaration */) { + else if (n.kind !== 165 /* FunctionExpression */ && n.kind !== 203 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 /* PropertyDeclaration */ && + return n.kind === 134 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -19741,7 +20650,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -19759,7 +20668,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137 /* GetAccessor */) { + if (node.kind === 138 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -19767,7 +20676,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 137 /* GetAccessor */ ? 138 /* SetAccessor */ : 137 /* GetAccessor */; + var otherKind = node.kind === 138 /* GetAccessor */ ? 139 /* SetAccessor */ : 138 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -19791,28 +20700,27 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { - // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -19864,9 +20772,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 /* CallSignature */ || signatureDeclarationNode.kind === 140 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 139 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 /* CallSignature */ || signatureDeclarationNode.kind === 141 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 140 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -19884,7 +20792,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -19967,7 +20875,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */); + ts.Debug.assert(node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -19996,7 +20904,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 /* InterfaceDeclaration */ || node.parent.kind === 146 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 /* InterfaceDeclaration */ || node.parent.kind === 148 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -20007,7 +20915,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 201 /* FunctionDeclaration */ || node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */ || node.kind === 136 /* Constructor */) { + if (node.kind === 203 /* FunctionDeclaration */ || node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */ || node.kind === 137 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20130,16 +21038,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -20151,43 +21059,51 @@ var ts; } /** Check a decorator */ function checkDecorator(node) { - var expression = node.expression; - var exprType = checkExpression(expression); + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1 /* Any */) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); - checkTypeAssignableTo(exprType, classDecoratorType, node); + expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 133 /* PropertyDeclaration */: - checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); + case 131 /* Parameter */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); - checkTypeAssignableTo(exprType, methodDecoratorType, node); - break; - case 130 /* Parameter */: - checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); break; } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node) { // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 142 /* TypeReference */) { + if (node && node.kind === 144 /* TypeReference */) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } @@ -20197,19 +21113,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 130 /* Parameter */: + case 131 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -20238,47 +21154,44 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 138 /* SetAccessor */: - case 137 /* GetAccessor */: - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 139 /* SetAccessor */: + case 138 /* GetAccessor */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130 /* Parameter */) { + if (node.kind === 131 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 129 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -20322,12 +21235,12 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207 /* ModuleBlock */) { - checkFunctionExpressionBodies(node); + if (ts.isFunctionBlock(node) || node.kind === 209 /* ModuleBlock */) { + checkFunctionAndClassExpressionBodies(node); } } function checkCollisionWithArgumentsInGeneratedCode(node) { @@ -20345,12 +21258,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 /* PropertyDeclaration */ || - node.kind === 132 /* PropertySignature */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */) { + if (node.kind === 134 /* PropertyDeclaration */ || + node.kind === 133 /* PropertySignature */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -20359,7 +21272,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -20392,7 +21305,7 @@ var ts; return; } // bubble up and find containing type - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClass = ts.getContainingClass(node); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; @@ -20412,12 +21325,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 208 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 228 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 230 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -20452,7 +21365,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 199 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 201 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -20462,17 +21375,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 181 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 183 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 180 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 207 /* ModuleBlock */ || - container.kind === 206 /* ModuleDeclaration */ || - container.kind === 228 /* SourceFile */); + (container.kind === 182 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 209 /* ModuleBlock */ || + container.kind === 208 /* ModuleDeclaration */ || + container.kind === 230 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -20487,7 +21400,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 131 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -20498,7 +21411,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 131 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -20518,14 +21431,13 @@ var ts; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -20536,7 +21448,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 130 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -20568,10 +21480,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 /* PropertyDeclaration */ && node.kind !== 132 /* PropertySignature */) { + if (node.kind !== 134 /* PropertyDeclaration */ && node.kind !== 133 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -20601,7 +21513,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 /* Block */ || node.kind === 155 /* ObjectLiteralExpression */) { + if (node.kind === 182 /* Block */ || node.kind === 157 /* ObjectLiteralExpression */) { return true; } node = node.parent; @@ -20634,12 +21546,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -20659,14 +21571,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -20695,7 +21607,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -20709,7 +21621,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -20948,7 +21860,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138 /* SetAccessor */))); + return !!(node.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -20961,7 +21873,8 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { // A generator does not need its return expressions checked against its return type. @@ -20970,27 +21883,22 @@ var ts; // for generators. return; } - if (func.kind === 138 /* SetAccessor */) { + if (func.kind === 139 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136 /* Constructor */) { + else if (func.kind === 137 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1 /* StrictMode */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -21002,7 +21910,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 222 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 224 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21014,7 +21922,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 223 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -21035,7 +21943,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 197 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -21083,9 +21991,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -21105,7 +22010,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 202 /* ClassDeclaration */) { + if (type.flags & 1024 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -21143,7 +22048,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 128 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21194,16 +22099,17 @@ var ts; } } function checkClassExpression(node) { - grammarErrorOnNode(node, ts.Diagnostics.class_expressions_are_not_currently_supported); - ts.forEach(node.members, checkSourceElement); - return unknownType; + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); - // Grammar checking if (!node.name && !(node.flags & 256 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); checkDecorators(node); if (node.name) { @@ -21218,36 +22124,42 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455 /* Value */)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - // Check that base type can be evaluated as expression - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -21262,7 +22174,6 @@ var ts; } }); } - ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -21335,7 +22246,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 /* GetAccessor */ || kind === 138 /* SetAccessor */; + return kind === 138 /* GetAccessor */ || kind === 139 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -21399,13 +22310,13 @@ var ts; } function checkInterfaceDeclaration(node) { // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -21427,7 +22338,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -21449,7 +22360,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -21489,7 +22400,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -21500,7 +22411,7 @@ var ts; case 47 /* TildeToken */: return ~value; } return undefined; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -21525,11 +22436,11 @@ var ts; return undefined; case 7 /* NumericLiteral */: return +e.text; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return evalConstant(e.expression); case 65 /* Identifier */: - case 157 /* ElementAccessExpression */: - case 156 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 158 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -21542,7 +22453,7 @@ var ts; } else { var expression; - if (e.kind === 157 /* ElementAccessExpression */) { + if (e.kind === 159 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -21560,7 +22471,7 @@ var ts; if (current.kind === 65 /* Identifier */) { break; } - else if (current.kind === 156 /* PropertyAccessExpression */) { + else if (current.kind === 158 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -21599,7 +22510,7 @@ var ts; return; } // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -21629,7 +22540,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 205 /* EnumDeclaration */) { + if (declaration.kind !== 207 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -21652,8 +22563,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 201 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 203 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -21676,7 +22587,15 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -21701,14 +22620,14 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 202 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 204 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; } } // Checks for ambient external modules. - if (node.name.kind === 8 /* StringLiteral */) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -21721,10 +22640,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { node = node.left; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -21740,9 +22659,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -21765,7 +22684,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 /* ExportSpecifier */ ? + var message = node.kind === 220 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -21778,7 +22697,11 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -21788,7 +22711,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -21799,7 +22722,11 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1 /* Export */) { @@ -21829,6 +22756,10 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + // If we hit an export in an illegal context, just bail out to avoid cascading errors. + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } @@ -21837,8 +22768,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -21851,6 +22782,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 /* SourceFile */ && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 208 /* ModuleDeclaration */) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -21858,8 +22794,12 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 206 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. + return; + } + var container = node.parent.kind === 230 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 208 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -21886,10 +22826,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228 /* SourceFile */) { + if (node.kind === 230 /* SourceFile */) { return node.statements; } - if (node.kind === 206 /* ModuleDeclaration */ && node.body.kind === 207 /* ModuleBlock */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.body.kind === 209 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -21914,116 +22854,123 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return checkTypeParameter(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return checkParameter(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return checkPropertyDeclaration(node); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return checkSignatureDeclaration(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return checkMethodDeclaration(node); - case 136 /* Constructor */: + case 137 /* Constructor */: return checkConstructorDeclaration(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return checkAccessorDeclaration(node); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return checkTypeReferenceNode(node); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return checkTypePredicate(node); + case 147 /* TypeQuery */: return checkTypeQuery(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return checkTypeLiteral(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return checkArrayType(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return checkTupleType(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return checkUnionType(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return checkSourceElement(node.type); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return checkBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return checkVariableStatement(node); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return checkExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return checkIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return checkDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return checkWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return checkForStatement(node); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return checkForInStatement(node); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return checkForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return checkReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return checkWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return checkSwitchStatement(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return checkLabeledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return checkThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return checkTryStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return checkBindingElement(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return checkClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return checkImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return checkExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return checkExportAssignment(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return checkMissingDeclaration(node); } } - // Function expression bodies are checked after all statements in the enclosing body. This is to ensure - // constructs like the following are permitted: + // Function and class expression bodies are checked after all statements in the enclosing body. This is + // to ensure constructs like the following are permitted: // let foo = function () { // let s = foo(); // return "hello"; @@ -22031,86 +22978,89 @@ var ts; // Here, performing a full type check of the body of the function expression whilst in the process of // determining the type of foo would cause foo to be given type any because of the recursive reference. // Delaying the type check of the body ensures foo has been assigned a type. - function checkFunctionExpressionBodies(node) { + function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - ts.forEach(node.decorators, checkFunctionExpressionBodies); - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 177 /* ClassExpression */: + ts.forEach(node.members, checkSourceElement); + break; + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 193 /* WithStatement */: - checkFunctionExpressionBodies(node.expression); + case 195 /* WithStatement */: + checkFunctionAndClassExpressionBodies(node.expression); break; - case 131 /* Decorator */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 153 /* BindingElement */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 225 /* PropertyAssignment */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 172 /* TemplateExpression */: - case 178 /* TemplateSpan */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 208 /* CaseBlock */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: - case 199 /* VariableDeclaration */: - case 200 /* VariableDeclarationList */: - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 215 /* ExportAssignment */: - case 228 /* SourceFile */: - ts.forEachChild(node, checkFunctionExpressionBodies); + case 132 /* Decorator */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 155 /* BindingElement */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 174 /* TemplateExpression */: + case 180 /* TemplateSpan */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 210 /* CaseBlock */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: + case 201 /* VariableDeclaration */: + case 202 /* VariableDeclarationList */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 217 /* ExportAssignment */: + case 230 /* SourceFile */: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } } @@ -22123,6 +23073,11 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } // Grammar checking checkGrammarSourceFile(node); emitExtends = false; @@ -22130,7 +23085,7 @@ var ts; emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); - checkFunctionExpressionBodies(node); + checkFunctionAndClassExpressionBodies(node); if (ts.isExternalModule(node)) { checkExternalModuleExports(node); } @@ -22172,7 +23127,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 195 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -22195,23 +23150,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 177 /* ClassExpression */: + if (location.name) { + copySymbol(location.symbol, meaning); + } + // Fall through + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -22240,80 +23200,45 @@ var ts; } } } - if (isInsideWithStatementBody(location)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return []; - } - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 228 /* SourceFile */: - if (!ts.isExternalModule(location)) - break; - case 206 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); - break; - case 205 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); - break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); - } - break; - case 163 /* FunctionExpression */: - if (location.name) { - copySymbol(location.symbol, meaning); - } - break; - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 /* Identifier */ && + return name.kind === 65 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129 /* TypeParameter */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 130 /* TypeParameter */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127 /* QualifiedName */) { + while (node.parent && node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 142 /* TypeReference */; + return node.parent && node.parent.kind === 144 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 158 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 179 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 128 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 211 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 217 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22325,11 +23250,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215 /* ExportAssignment */) { + if (entityName.parent.kind === 217 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 156 /* PropertyAccessExpression */) { + if (entityName.kind !== 158 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -22339,7 +23264,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 179 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } @@ -22354,14 +23279,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156 /* PropertyAccessExpression */) { + else if (entityName.kind === 158 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127 /* QualifiedName */) { + else if (entityName.kind === 128 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -22370,12 +23295,15 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 144 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } + if (entityName.parent.kind === 143 /* TypePredicate */) { + return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + } // Do we want to return undefined here? return undefined; } @@ -22389,14 +23317,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 /* ExportAssignment */ + return node.parent.kind === 217 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: @@ -22405,7 +23333,7 @@ var ts; case 114 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 137 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -22414,14 +23342,14 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 /* ImportDeclaration */ || node.parent.kind === 216 /* ExportDeclaration */) && + ((node.parent.kind === 212 /* ImportDeclaration */ || node.parent.kind === 218 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Intentional fall-through case 7 /* NumericLiteral */: // index access - if (node.parent.kind == 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -22438,7 +23366,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 226 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 228 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -22454,6 +23382,11 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration var symbol = getSymbolOfNode(node); @@ -22485,6 +23418,16 @@ var ts; } return checkExpression(expr); } + /** + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 /* Static */ + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } // Return the list of properties of the given type, augmented with properties from Function // if the type has call or construct signatures function getAugmentedPropertiesOfType(type) { @@ -22517,93 +23460,92 @@ var ts; return [symbol]; } // Emitter support - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228 /* SourceFile */; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - // If this is es6 or higher, just use the name of the export - // no need to qualify it. - if (languageVersion >= 2 /* ES6 */) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211 /* ImportClause */) { - var defaultKeyword; - if (languageVersion === 0 /* ES3 */) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214 /* ImportSpecifier */) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - // 1. If this is es6 or higher, just use the name of the export - // no need to qualify it. - // 2. export mechanism for System modules is different from CJS\AMD - // and it does not need qualifications for exports - if (languageVersion >= 2 /* ES6 */ || compilerOptions.module === 4 /* System */) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 /* ModuleDeclaration */ || node.kind === 205 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration + // node of the exported entity's container. Otherwise, return undefined. + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - // Whan an identifier resolves to a parented symbol, it references an exported entity from - // another declaration of the same internal module. - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576 /* ExportValue */) { + // If we reference an exported entity within the same module declaration, then whether + // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the + // kinds that we do NOT prefix. + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944 /* ExportHasLocal */) { + return undefined; + } + symbol = exportSymbol; } - // If we reference an exported entity within the same module declaration, then whether - // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the - // kinds that we do NOT prefix. - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - // Named imports from ES6 import declarations are rewritten - if (symbol.flags & 8388608 /* Alias */) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 230 /* SourceFile */) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 /* ModuleDeclaration */ || n.kind === 207 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + // When resolved as an expression identifier, if the given node references an import, return the declaration of + // that import. Otherwise, return undefined. + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182 /* Block */: + case 210 /* CaseBlock */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418 /* BlockScoped */) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + // When resolved as an expression identifier, if the given node references a nested block scoped entity with + // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an + // existing name. + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -22661,7 +23603,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227 /* EnumMember */) { + if (node.kind === 229 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -22674,10 +23616,13 @@ var ts; return undefined; } /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65 /* Identifier */) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it + // here has no effect anyway as an identifier in a type name is not an expression. + // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); + // var text = substitution || (node).text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -22686,15 +23631,15 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { // serialization of a TypeReferenceNode uses the following rules: // // * The serialized type of a TypeReference that is `void` is "void 0". @@ -22727,11 +23672,11 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; @@ -22739,7 +23684,7 @@ var ts; return "Object"; } /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { // serialization of a TypeNode uses the following rules: // // * The serialized type of `void` is "void 0" (undefined). @@ -22754,26 +23699,26 @@ var ts; switch (node.kind) { case 99 /* VoidKeyword */: return "void 0"; - case 150 /* ParenthesizedType */: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 152 /* ParenthesizedType */: + return serializeTypeNode(node.type); + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return "Function"; - case 147 /* ArrayType */: - case 148 /* TupleType */: + case 149 /* ArrayType */: + case 150 /* TupleType */: return "Array"; case 113 /* BooleanKeyword */: return "Boolean"; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: case 8 /* StringLiteral */: return "String"; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return "Number"; - case 142 /* TypeReference */: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145 /* TypeQuery */: - case 146 /* TypeLiteral */: - case 149 /* UnionType */: + case 144 /* TypeReference */: + return serializeTypeReferenceNode(node); + case 147 /* TypeQuery */: + case 148 /* TypeLiteral */: + case 151 /* UnionType */: case 112 /* AnyKeyword */: break; default: @@ -22784,7 +23729,7 @@ var ts; return "Object"; } /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { // serialization of the type of a declaration uses the following rules: // // * The serialized type of a ClassDeclaration is "Function" @@ -22796,11 +23741,11 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 202 /* ClassDeclaration */: return "Function"; - case 133 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204 /* ClassDeclaration */: return "Function"; + case 134 /* PropertyDeclaration */: return serializeTypeNode(node.type); + case 131 /* Parameter */: return serializeTypeNode(node.type); + case 138 /* GetAccessor */: return serializeTypeNode(node.type); + case 139 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; @@ -22808,7 +23753,7 @@ var ts; return "void 0"; } /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. @@ -22817,7 +23762,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -22832,19 +23777,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147 /* ArrayType */) { + if (parameterType.kind === 149 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -22854,9 +23799,9 @@ var ts; return emptyArray; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -22879,25 +23824,25 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455 /* Value */, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, + /*nodeNotFoundMessage*/ undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 /* BindingElement */ || (n.parent.kind === 199 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 /* BindingElement */ || (n.parent.kind === 201 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 224 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 226 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -22919,7 +23864,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -22933,7 +23881,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -22966,10 +23913,7 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -22994,137 +23938,6 @@ var ts; anyArrayType = createArrayType(anyType); } // GRAMMAR CHECKING - function isReservedWordInStrictMode(node) { - // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word - return (node.parserContextFlags & 1 /* StrictMode */) && - (102 /* FirstFutureReservedWord */ <= node.originalKeywordKind && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) - // if so, we would like to give more explicit invalid usage error. - if (ts.getAncestor(identifier, 202 /* ClassDeclaration */) || ts.getAncestor(identifier, 175 /* ClassExpression */)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - // Check if the import declaration used strict-mode reserved word in its names bindings - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212 /* NamespaceImport */) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213 /* NamedImports */) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 /* Identifier */ && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 201 /* FunctionDeclaration */: - case 129 /* TypeParameter */: - case 153 /* BindingElement */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - return checkGrammarIdentifierInStrictMode(name); - case 202 /* ClassDeclaration */: - // Report an error if the class declaration uses strict-mode reserved word. - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206 /* ModuleDeclaration */: - // Report an error if the module declaration uses strict-mode reserved word. - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209 /* ImportEqualsDeclaration */: - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - // Check if the type reference is using strict mode keyword - // Example: - // class C { - // foo(x: public){} // Error. - // } - if (typeName.kind === 65 /* Identifier */) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127 /* QualifiedName */) { - // Walk from right to left and report a possible error at each Identifier in QualifiedName - // Example: - // x1: public.private.package // error at public and private - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - // This function will report an error for every identifier in property access expression - // whether it violates strict mode reserved words. - // Example: - // public // error at public - // public.private.package // error at public - // B.private.B // no error - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - // Example: - // class C extends public // error at public - if (expression && expression.kind === 65 /* Identifier */) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156 /* PropertyAccessExpression */) { - // Walk from left to right in PropertyAccessExpression until we are at the left most expression - // in PropertyAccessExpression. According to grammar production of MemberExpression, - // the left component expression is a PrimaryExpression (i.e. Identifier) while the other - // component after dots can be IdentifierName. - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - // The function takes an identifier when uses as a typeName in TypeReferenceNode - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -23135,7 +23948,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 /* GetAccessor */ || node.kind === 138 /* SetAccessor */) { + else if (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -23145,33 +23958,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 206 /* ModuleDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 130 /* Parameter */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 208 /* ModuleDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 131 /* Parameter */: break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 204 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 206 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70 /* ConstKeyword */) && - node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23207,7 +24020,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -23216,10 +24029,10 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; @@ -23232,10 +24045,10 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -23244,13 +24057,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -23258,7 +24071,7 @@ var ts; break; } } - if (node.kind === 136 /* Constructor */) { + if (node.kind === 137 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -23269,10 +24082,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -23336,7 +24149,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164 /* ArrowFunction */) { + if (node.kind === 166 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23371,7 +24184,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 /* StringKeyword */ && parameter.type.kind !== 120 /* NumberKeyword */) { + if (parameter.type.kind !== 123 /* StringKeyword */ && parameter.type.kind !== 121 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -23404,7 +24217,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176 /* OmittedExpression */) { + if (arg.kind === 178 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23478,19 +24291,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 128 /* ComputedPropertyName */) { + if (node.kind !== 129 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 172 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -23502,10 +24315,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -23517,14 +24326,13 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 /* OmittedExpression */ || - name_17.kind === 128 /* ComputedPropertyName */) { + var name_15 = prop.name; + if (prop.kind === 178 /* OmittedExpression */ || + name_15.kind === 129 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_17); + checkGrammarComputedPropertyName(name_15); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -23536,46 +24344,44 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 225 /* PropertyAssignment */ || prop.kind === 226 /* ShorthandPropertyAssignment */) { + if (prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135 /* MethodDeclaration */) { + else if (prop.kind === 136 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 137 /* GetAccessor */) { + else if (prop.kind === 138 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 138 /* SetAccessor */) { + else if (prop.kind === 139 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -23584,24 +24390,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -23624,10 +24430,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 138 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138 /* SetAccessor */) { + else if (kind === 139 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -23652,7 +24458,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -23662,7 +24468,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155 /* ObjectLiteralExpression */) { + if (node.parent.kind === 157 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23670,7 +24476,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23686,22 +24492,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return true; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -23713,11 +24519,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 190 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 192 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -23725,8 +24531,8 @@ var ts; return false; } break; - case 194 /* SwitchStatement */: - if (node.kind === 191 /* BreakStatement */ && !node.label) { + case 196 /* SwitchStatement */: + if (node.kind === 193 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -23741,13 +24547,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -23759,7 +24565,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) { + if (node.name.kind === 154 /* ArrayBindingPattern */ || node.name.kind === 153 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -23767,12 +24573,9 @@ var ts; return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 /* ForInStatement */ && node.parent.parent.kind !== 189 /* ForOfStatement */) { + if (node.parent.parent.kind !== 190 /* ForInStatement */ && node.parent.parent.kind !== 191 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -23796,8 +24599,7 @@ var ts; // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65 /* Identifier */) { @@ -23809,7 +24611,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -23826,15 +24628,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return false; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -23850,7 +24652,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168 /* PrefixUnaryExpression */) { + if (expression.kind === 170 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; @@ -23879,7 +24681,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -23921,26 +24723,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65 /* Identifier */) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -23952,18 +24734,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -23983,11 +24765,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 203 /* InterfaceDeclaration */ || - node.kind === 210 /* ImportDeclaration */ || - node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 216 /* ExportDeclaration */ || - node.kind === 215 /* ExportAssignment */ || + if (node.kind === 205 /* InterfaceDeclaration */ || + node.kind === 212 /* ImportDeclaration */ || + node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 218 /* ExportDeclaration */ || + node.kind === 217 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 256 /* Default */))) { return false; @@ -23997,7 +24779,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 183 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24023,7 +24805,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 180 /* Block */ || node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + if (node.parent.kind === 182 /* Block */ || node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -24036,13 +24818,8 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 16384 /* OctalLiteral */) { - if (node.parserContextFlags & 1 /* StrictMode */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -24053,8 +24830,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -24113,7 +24888,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 212 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -24189,10 +24964,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199 /* VariableDeclaration */) { + if (declaration.kind === 201 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 /* NamedImports */ || declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 211 /* ImportClause */) { + else if (declaration.kind === 215 /* NamedImports */ || declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 213 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24210,7 +24985,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 212 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -24220,12 +24995,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24318,41 +25093,41 @@ var ts; function emitType(type) { switch (type.kind) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return emitTypeReference(type); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return emitTypeQuery(type); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return emitArrayType(type); - case 148 /* TupleType */: + case 150 /* TupleType */: return emitTupleType(type); - case 149 /* UnionType */: + case 151 /* UnionType */: return emitUnionType(type); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return emitParenType(type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return emitTypeLiteral(type); case 65 /* Identifier */: return emitEntityName(type); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitEntityName(type); } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 209 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 211 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -24360,8 +25135,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 127 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 128 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 128 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -24370,7 +25145,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 156 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 158 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -24436,9 +25211,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -24482,10 +25257,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 /* ImportEqualsDeclaration */ || - (node.parent.kind === 228 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 /* ImportEqualsDeclaration */ || + (node.parent.kind === 230 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -24495,7 +25270,7 @@ var ts; }); } else { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -24513,23 +25288,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return writeVariableStatement(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return writeClassDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -24545,7 +25320,7 @@ var ts; if (node.flags & 256 /* Default */) { write("default "); } - else if (node.kind !== 203 /* InterfaceDeclaration */) { + else if (node.kind !== 205 /* InterfaceDeclaration */) { write("declare "); } } @@ -24591,7 +25366,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -24619,7 +25394,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -24670,9 +25445,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207 /* ModuleBlock */) { + while (node.body.kind !== 209 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -24733,7 +25513,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 136 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -24744,15 +25524,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 146 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 135 /* MethodDeclaration */ || - node.parent.kind === 134 /* MethodSignature */ || - node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.kind === 139 /* CallSignature */ || - node.parent.kind === 140 /* ConstructSignature */); + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 148 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 136 /* MethodDeclaration */ || + node.parent.kind === 135 /* MethodSignature */ || + node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.kind === 140 /* CallSignature */ || + node.parent.kind === 141 /* ConstructSignature */); emitType(node.constraint); } else { @@ -24763,31 +25543,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -24818,7 +25598,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -24899,7 +25679,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 199 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -24909,10 +25689,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && node.parent.kind === 146 /* TypeLiteral */) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && node.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -24921,14 +25701,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) { + else if (node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -24937,7 +25717,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24969,7 +25749,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { elements.push(element); } } @@ -25039,7 +25819,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 137 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25052,7 +25832,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 /* GetAccessor */ + return accessor.kind === 138 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -25061,7 +25841,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 139 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -25111,17 +25891,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135 /* MethodDeclaration */) { + else if (node.kind === 136 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136 /* Constructor */) { + else if (node.kind === 137 /* Constructor */) { write("constructor"); } else { @@ -25139,11 +25919,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 140 /* ConstructSignature */ || node.kind === 144 /* ConstructorType */) { + if (node.kind === 141 /* ConstructSignature */ || node.kind === 146 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("["); } else { @@ -25153,22 +25933,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 143 /* FunctionType */ || node.kind === 144 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 145 /* FunctionType */ || node.kind === 146 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 137 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25179,26 +25959,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25206,7 +25986,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25220,7 +26000,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25255,9 +26035,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.parent.kind === 146 /* TypeLiteral */) { + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -25273,24 +26053,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25298,7 +26078,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25311,7 +26091,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25323,12 +26103,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 151 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 153 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 154 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25347,7 +26127,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176 /* OmittedExpression */) { + if (bindingElement.kind === 178 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -25356,7 +26136,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 153 /* BindingElement */) { + else if (bindingElement.kind === 155 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -25397,40 +26177,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 203 /* InterfaceDeclaration */: - case 202 /* ClassDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 203 /* FunctionDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 205 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return writeFunctionDeclaration(node); - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessorDeclaration(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return emitPropertyDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFile(node); } } @@ -25491,7 +26271,7 @@ var ts; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function @@ -25567,7 +26347,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -25647,9 +26426,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -25672,73 +26451,44 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65 /* Identifier */) { - var name_20 = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65 /* Identifier */) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForClassExpression() { + return makeUniqueName("class"); } function generateNameForNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206 /* ModuleDeclaration */: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205 /* EnumDeclaration */: - generateNameForModuleOrEnum(node); - break; - case 210 /* ImportDeclaration */: - generateNameForImportDeclaration(node); - break; - case 216 /* ExportDeclaration */: - generateNameForExportDeclaration(node); - break; - case 215 /* ExportAssignment */: - generateNameForExportAssignment(node); - break; + case 65 /* Identifier */: + return makeUniqueName(node.text); + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 212 /* ImportDeclaration */: + case 218 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 217 /* ExportAssignment */: + return generateNameForExportDefault(); + case 177 /* ClassExpression */: + return generateNameForClassExpression(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; // The directory in which sourcemap will be @@ -25767,7 +26517,7 @@ var ts; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { // Emit comma to separate the entry if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; @@ -25836,8 +26586,8 @@ var ts; var emittedColumn = writer.getColumn(); // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -25903,8 +26653,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128 /* ComputedPropertyName */) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -25922,21 +26672,21 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */ || - node.kind === 206 /* ModuleDeclaration */ || - node.kind === 202 /* ClassDeclaration */ || - node.kind === 205 /* EnumDeclaration */) { + else if (node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */ || + node.kind === 208 /* ModuleDeclaration */ || + node.kind === 204 /* ClassDeclaration */ || + node.kind === 207 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_22 = node.name; + var name_19 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 128 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) + scopeName = name_19.kind === 129 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -26040,19 +26790,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228 /* SourceFile */) { + if (node.kind !== 230 /* SourceFile */) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -26308,10 +27058,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 172 /* TemplateExpression */) { + if (node.template.kind === 174 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 172 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26346,7 +27096,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 162 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 164 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -26388,11 +27138,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent.expression === template; - case 160 /* TaggedTemplateExpression */: - case 162 /* ParenthesizedExpression */: + case 162 /* TaggedTemplateExpression */: + case 164 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -26413,7 +27163,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 35 /* AsteriskToken */: case 36 /* SlashToken */: @@ -26425,8 +27175,8 @@ var ts; default: return -1 /* LessThan */; } - case 173 /* YieldExpression */: - case 171 /* ConditionalExpression */: + case 175 /* YieldExpression */: + case 173 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -26441,11 +27191,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153 /* BindingElement */); + ts.Debug.assert(node.kind !== 155 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 128 /* ComputedPropertyName */) { + else if (node.kind === 129 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -26486,75 +27236,126 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - return parent.name === node; - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: - return parent.name === node || parent.propertyName === node; - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 215 /* ExportAssignment */: - return false; - case 195 /* LabeledStatement */: - return node.parent.label === node; + case 156 /* ArrayLiteralExpression */: + case 172 /* BinaryExpression */: + case 160 /* CallExpression */: + case 223 /* CaseClause */: + case 129 /* ComputedPropertyName */: + case 173 /* ConditionalExpression */: + case 132 /* Decorator */: + case 167 /* DeleteExpression */: + case 187 /* DoStatement */: + case 159 /* ElementAccessExpression */: + case 217 /* ExportAssignment */: + case 185 /* ExpressionStatement */: + case 179 /* ExpressionWithTypeArguments */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 186 /* IfStatement */: + case 161 /* NewExpression */: + case 164 /* ParenthesizedExpression */: + case 171 /* PostfixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: + case 194 /* ReturnStatement */: + case 228 /* ShorthandPropertyAssignment */: + case 176 /* SpreadElementExpression */: + case 196 /* SwitchStatement */: + case 162 /* TaggedTemplateExpression */: + case 180 /* TemplateSpan */: + case 198 /* ThrowStatement */: + case 163 /* TypeAssertionExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 175 /* YieldExpression */: + return true; + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 201 /* VariableDeclaration */: + return parent.initializer === node; + case 158 /* PropertyAccessExpression */: + return parent.expression === node; + case 166 /* ArrowFunction */: + case 165 /* FunctionExpression */: + return parent.body === node; + case 211 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 128 /* QualifiedName */: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230 /* SourceFile */) { + // Identifier references module export + if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 201 /* VariableDeclaration */: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -26595,7 +27396,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -26626,11 +27427,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: - case 154 /* ArrayLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: + case 156 /* ArrayLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -26650,17 +27451,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174 /* SpreadElementExpression */) { + if (e.kind === 176 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 176 /* SpreadElementExpression */) { i++; } write("["); @@ -26683,7 +27484,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174 /* SpreadElementExpression */; + return node.kind === 176 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -26753,7 +27554,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 /* GetAccessor */ || property.kind === 138 /* SetAccessor */) { + if (property.kind === 138 /* GetAccessor */ || property.kind === 139 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -26805,13 +27606,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225 /* PropertyAssignment */) { + if (property.kind === 227 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 226 /* ShorthandPropertyAssignment */) { + else if (property.kind === 228 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135 /* MethodDeclaration */) { + else if (property.kind === 136 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -26845,7 +27646,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128 /* ComputedPropertyName */) { + if (properties[i].name.kind === 129 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -26861,21 +27662,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(172 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(158 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(159 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -26883,7 +27684,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 161 /* TypeAssertionExpression */) { + while (expr.kind === 163 /* TypeAssertionExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -26895,11 +27696,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 /* NewExpression */ && + expr.kind !== 161 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(164 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -26912,46 +27713,39 @@ var ts; if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2 /* ES6 */) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230 /* SourceFile */; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // export let obj = { y }; - // } - // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (languageVersion < 2 /* ES6 */) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - // Emit identifier as an identifier - write(": "); - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -26963,7 +27757,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -26997,7 +27791,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -27015,10 +27809,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 176 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 162 /* ParenthesizedExpression */ || node.kind === 161 /* TypeAssertionExpression */) { + while (node.kind === 164 /* ParenthesizedExpression */ || node.kind === 163 /* TypeAssertionExpression */) { node = node.expression; } return node; @@ -27039,13 +27833,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157 /* ElementAccessExpression */) { + else if (expr.kind === 159 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -27090,7 +27884,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 158 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -27109,23 +27903,21 @@ var ts; } function emitNewExpression(node) { write("new "); - // Spread operator logic can be supported in new expressions in ES5 using a combination + // Spread operator logic is supported in new expressions in ES5 using a combination // of Function.prototype.bind() and Function.prototype.apply(). // // Example: // - // var arguments = [1, 2, 3, 4, 5]; - // new Array(...arguments); + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); // - // Could be transpiled into ES5: + // is compiled into the following ES5: // - // var arguments = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(arguments))); + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); // - // `[void 0]` is the first argument which represents `thisArg` to the bind method above. - // And `thisArg` will be set to the return value of the constructor when instantiated - // with the new operator — regardless of any value we set `thisArg` to. Thus, we set it - // to an undefined, `void 0`. + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). if (languageVersion === 1 /* ES5 */ && node.arguments && hasSpreadElement(node.arguments)) { @@ -27161,12 +27953,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164 /* ArrowFunction */) { - if (node.expression.kind === 161 /* TypeAssertionExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166 /* ArrowFunction */) { + if (node.expression.kind === 163 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == 161 /* TypeAssertionExpression */) { + while (operand.kind === 163 /* TypeAssertionExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -27177,14 +27969,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 168 /* PrefixUnaryExpression */ && - operand.kind !== 167 /* VoidExpression */ && - operand.kind !== 166 /* TypeOfExpression */ && - operand.kind !== 165 /* DeleteExpression */ && - operand.kind !== 169 /* PostfixUnaryExpression */ && - operand.kind !== 159 /* NewExpression */ && - !(operand.kind === 158 /* CallExpression */ && node.parent.kind === 159 /* NewExpression */) && - !(operand.kind === 163 /* FunctionExpression */ && node.parent.kind === 158 /* CallExpression */)) { + if (operand.kind !== 170 /* PrefixUnaryExpression */ && + operand.kind !== 169 /* VoidExpression */ && + operand.kind !== 168 /* TypeOfExpression */ && + operand.kind !== 167 /* DeleteExpression */ && + operand.kind !== 171 /* PostfixUnaryExpression */ && + operand.kind !== 161 /* NewExpression */ && + !(operand.kind === 160 /* CallExpression */ && node.parent.kind === 161 /* NewExpression */) && + !(operand.kind === 165 /* FunctionExpression */ && node.parent.kind === 160 /* CallExpression */)) { emit(operand); return; } @@ -27213,7 +28005,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 /* VariableDeclaration */ || node.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 /* VariableDeclaration */ || node.parent.kind === 155 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27243,7 +28035,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 168 /* PrefixUnaryExpression */) { + if (node.operand.kind === 170 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); @@ -27299,10 +28091,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228 /* SourceFile */) { + if (current.kind === 230 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 209 /* ModuleBlock */) { return false; } else { @@ -27312,8 +28104,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 183 /* ExpressionStatement */); + (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 185 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && @@ -27365,7 +28157,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180 /* Block */) { + if (node && node.kind === 182 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -27380,12 +28172,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 206 /* ModuleDeclaration */); + if (node.kind === 209 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 208 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207 /* ModuleBlock */) { + if (node.kind === 209 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -27394,7 +28186,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { write(" "); emit(node); } @@ -27406,7 +28198,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 166 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -27419,7 +28211,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 184 /* IfStatement */) { + if (node.elseStatement.kind === 186 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -27431,7 +28223,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { write(" "); } else { @@ -27506,7 +28298,7 @@ var ts; var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -27527,13 +28319,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 189 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 191 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -27543,7 +28335,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188 /* ForInStatement */) { + if (node.kind === 190 /* ForInStatement */) { write(" in "); } else { @@ -27628,7 +28420,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -27658,7 +28450,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 154 /* ArrayLiteralExpression */ || node.initializer.kind === 155 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 156 /* ArrayLiteralExpression */ || node.initializer.kind === 157 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, true, undefined); @@ -27669,7 +28461,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { emitLines(node.statement.statements); } else { @@ -27681,7 +28473,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -27726,7 +28518,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221 /* CaseClause */) { + if (node.kind === 223 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -27781,7 +28573,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206 /* ModuleDeclaration */); + } while (node && node.kind !== 208 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -27806,7 +28598,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(167 /* VoidExpression */); + var result = ts.createSynthesizedNode(169 /* VoidExpression */); result.expression = zero; return result; } @@ -27882,15 +28674,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 199 /* VariableDeclaration */) { + if (root.kind === 201 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130 /* Parameter */) { + else if (root.kind === 131 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170 /* BinaryExpression */) { + if (root.kind === 172 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -27901,8 +28693,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 /* VariableDeclaration */ || name.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 /* VariableDeclaration */ || name.parent.kind === 155 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -27937,14 +28728,14 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(170 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(172 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(173 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -27958,13 +28749,17 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65 /* Identifier */) { - return createElementAccessExpression(object, propName); + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158 /* CallExpression */); + var call = ts.createSynthesizedNode(160 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -27981,9 +28776,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var propName = (p.name); + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -27997,8 +28791,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -28008,14 +28802,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154 /* ArrayLiteralExpression */) { + else if (target.kind === 156 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -28029,14 +28823,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write(")"); } } @@ -28060,12 +28854,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176 /* OmittedExpression */) { + else if (element.kind !== 178 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -28092,7 +28886,6 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2 /* ES6 */) { // downlevel emit for non-initialized let bindings defined in loops @@ -28105,8 +28898,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 188 /* ForInStatement */ && - node.parent.parent.kind !== 189 /* ForOfStatement */) { + node.parent.parent.kind !== 190 /* ForInStatement */ && + node.parent.parent.kind !== 191 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -28124,7 +28917,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176 /* OmittedExpression */) { + if (node.kind === 178 /* OmittedExpression */) { return; } var name = node.name; @@ -28136,56 +28929,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 201 /* VariableDeclaration */ && node.parent.kind !== 155 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - // do not rename if - // - language version is ES6+ - // - node is synthesized - // - node is not identifier (can happen when tree is malformed) - // - node is definitely not name of variable declaration. - // it still can be part of parameter declaration, this check will be done next - if (languageVersion >= 2 /* ES6 */ || - ts.nodeIsSynthesized(node) || - node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288 /* BlockScoped */) === 0) || combinedFlags & 1 /* Export */) { - // do not rename exported or non-block scoped variables - return; - } - // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 200 /* VariableDeclarationList */); - if (list.parent.kind === 181 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 207 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 180 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 /* SourceFile */ - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 228 /* SourceFile */; + node.parent.kind === 230 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28236,12 +28988,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_20 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -28332,12 +29084,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 /* GetAccessor */ ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 /* GetAccessor */ ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 166 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -28348,11 +29100,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163 /* FunctionExpression */) { + if (node.kind === 165 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -28361,7 +29113,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -28384,10 +29136,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { emitTrailingComments(node); } } @@ -28438,7 +29190,7 @@ var ts; // in that case. write(" { }"); } - else if (node.body.kind === 180 /* Block */) { + else if (node.body.kind === 182 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -28469,10 +29221,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 161 /* TypeAssertionExpression */) { + while (current.kind === 163 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 157 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -28548,9 +29300,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183 /* ExpressionStatement */) { + if (statement && statement.kind === 185 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 158 /* CallExpression */) { + if (expr && expr.kind === 160 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 91 /* SuperKeyword */) { return statement; @@ -28582,7 +29334,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128 /* ComputedPropertyName */) { + else if (memberName.kind === 129 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -28594,7 +29346,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 134 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -28634,11 +29386,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179 /* SemicolonClassElement */) { + if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) { + else if (member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -28657,7 +29409,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) { + else if (member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -28707,22 +29459,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) && !member.body) { + if ((member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 /* MethodDeclaration */ || - member.kind === 137 /* GetAccessor */ || - member.kind === 138 /* SetAccessor */) { + else if (member.kind === 136 /* MethodDeclaration */ || + member.kind === 138 /* GetAccessor */ || + member.kind === 139 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 137 /* GetAccessor */) { + if (member.kind === 138 /* GetAccessor */) { write("get "); } - else if (member.kind === 138 /* SetAccessor */) { + else if (member.kind === 139 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -28733,7 +29485,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179 /* SemicolonClassElement */) { + else if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -28758,11 +29510,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && !member.body) { + if (member.kind === 137 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 133 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 134 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28870,7 +29622,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -28950,7 +29702,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -29034,7 +29786,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -29093,11 +29845,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -29189,7 +29941,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 135 /* MethodDeclaration */) { + if (member.kind === 136 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -29227,7 +29979,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29257,7 +30009,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29299,10 +30051,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: return true; } return false; @@ -29312,7 +30064,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: return true; } return false; @@ -29322,9 +30074,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 202 /* ClassDeclaration */: - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return true; } return false; @@ -29335,7 +30087,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -29348,7 +30100,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -29366,7 +30118,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -29466,7 +30218,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -29500,7 +30252,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -29536,7 +30288,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207 /* ModuleBlock */) { + if (node.body.kind === 209 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -29576,7 +30328,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -29594,16 +30346,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 212 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -29631,7 +30383,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -29657,7 +30409,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 211 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -29676,7 +30428,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 210 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 212 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -29840,8 +30592,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 /* FunctionDeclaration */ && - expression.kind !== 202 /* ClassDeclaration */) { + if (expression.kind !== 203 /* FunctionDeclaration */ && + expression.kind !== 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -29877,7 +30629,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -29887,13 +30639,13 @@ var ts; externalImports.push(node); } break; - case 209 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 220 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 211 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 222 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -29909,12 +30661,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -29935,13 +30687,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -29960,8 +30715,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 216 /* ExportDeclaration */ || - (importNode.kind === 210 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 218 /* ExportDeclaration */ || + (importNode.kind === 212 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -29994,7 +30749,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 218 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30026,7 +30781,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216 /* ExportDeclaration */) { + if (externalImport.kind !== 218 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -30110,12 +30865,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 /* Identifier */ + var name_22 = local.kind === 65 /* Identifier */ ? local : local.name; - if (name_25) { + if (name_22) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30126,7 +30881,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */ || local.kind === 205 /* EnumDeclaration */) { + if (local.kind === 204 /* ClassDeclaration */ || local.kind === 208 /* ModuleDeclaration */ || local.kind === 207 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -30160,21 +30915,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205 /* EnumDeclaration */) { + if (node.kind === 207 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30183,7 +30938,7 @@ var ts; } return; } - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30192,17 +30947,17 @@ var ts; } return; } - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65 /* Identifier */) { + var name_23 = node.name; + if (name_23.kind === 65 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -30226,7 +30981,7 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 230 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); @@ -30279,10 +31034,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); // return + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -30297,21 +31052,21 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!importNode.importClause) { // 'import "..."' case // module is imported only for side-effects, setter body will be empty break; } // fall-through - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 /* ImportDeclaration */ + var defaultName = importNode.kind === 212 /* ImportDeclaration */ ? importNode.importClause.name : importNode.name; if (defaultName) { @@ -30323,10 +31078,10 @@ var ts; emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 /* ImportDeclaration */ && + if (importNode.kind === 212 /* ImportDeclaration */ && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { // emit re-export for namespace // import * as n from 'foo' // export {n} @@ -30346,7 +31101,7 @@ var ts; } decreaseIndent(); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -30389,10 +31144,10 @@ var ts; // - imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 216 /* ExportDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 201 /* FunctionDeclaration */: + case 218 /* ExportDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 203 /* FunctionDeclaration */: continue; } writeLine(); @@ -30415,7 +31170,11 @@ var ts; ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -30495,8 +31254,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -30634,7 +31393,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -30645,7 +31404,7 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } @@ -30654,20 +31413,20 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 215 /* ExportAssignment */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 217 /* ExportAssignment */: return false; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -30676,9 +31435,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 180 /* Block */ && + if (node.kind !== 182 /* Block */ && node.parent && - node.parent.kind === 164 /* ArrowFunction */ && + node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -30686,19 +31445,18 @@ var ts; // Emit comments for everything else. return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { case 65 /* Identifier */: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130 /* Parameter */: + return emitIdentifier(node); + case 131 /* Parameter */: return emitParameter(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return emitMethod(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessor(node); case 93 /* ThisKeyword */: return emitThis(node); @@ -30718,131 +31476,131 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return emitTemplateExpression(node); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return emitTemplateSpan(node); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitQualifiedName(node); - case 151 /* ObjectBindingPattern */: + case 153 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 152 /* ArrayBindingPattern */: + case 154 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return emitBindingElement(node); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 226 /* ShorthandPropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 158 /* CallExpression */: + case 160 /* CallExpression */: return emitCallExpression(node); - case 159 /* NewExpression */: + case 161 /* NewExpression */: return emitNewExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return emit(node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return emitParenExpression(node); - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return emitDeleteExpression(node); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return emitVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return emitBinaryExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return emitConditionalExpression(node); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return emitYieldExpression(node); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return; - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return emitBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitVariableStatement(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: return write(";"); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return emitExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return emitIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return emitDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return emitWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return emitForStatement(node); - case 189 /* ForOfStatement */: - case 188 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 190 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return emitReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return emitWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return emitSwitchStatement(node); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return emitLabelledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return emitThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return emitTryStatement(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return emitCatchClause(node); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return emitClassExpression(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return emitClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMember(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return emitImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFileNode(node); } } @@ -30874,7 +31632,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -30889,7 +31647,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 230 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -31086,7 +31844,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -31119,16 +31877,21 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -31138,11 +31901,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -31153,6 +31917,18 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + // Initialize a checker so that all our files are bound. + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -31192,8 +31968,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -31233,16 +32008,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -31276,14 +32049,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -31298,18 +32074,18 @@ var ts; // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } // We haven't looked for this file, do so now and cache result - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -31317,16 +32093,18 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path - filesByName[canonicalAbsolutePath] = file; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -31336,7 +32114,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -31354,7 +32132,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */ || node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */ || node.kind === 218 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -31375,7 +32153,7 @@ var ts; } } } - else if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -31656,9 +32434,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, @@ -32033,7 +32816,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 164 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 166 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -32045,30 +32828,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 180 /* Block */: + case 182 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 185 /* DoStatement */ || - parent_7.kind === 188 /* ForInStatement */ || - parent_7.kind === 189 /* ForOfStatement */ || - parent_7.kind === 187 /* ForStatement */ || - parent_7.kind === 184 /* IfStatement */ || - parent_7.kind === 186 /* WhileStatement */ || - parent_7.kind === 193 /* WithStatement */ || - parent_7.kind === 224 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 187 /* DoStatement */ || + parent_8.kind === 190 /* ForInStatement */ || + parent_8.kind === 191 /* ForOfStatement */ || + parent_8.kind === 189 /* ForStatement */ || + parent_8.kind === 186 /* IfStatement */ || + parent_8.kind === 188 /* WhileStatement */ || + parent_8.kind === 195 /* WithStatement */ || + parent_8.kind === 226 /* CatchClause */) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 197 /* TryStatement */) { + if (parent_8.kind === 199 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_7; + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -32091,23 +32874,23 @@ var ts; break; } // Fallthrough. - case 207 /* ModuleBlock */: { + case 209 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 208 /* CaseBlock */: { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 210 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -32135,12 +32918,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_27 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_27); + for (var name_24 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_24); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_27); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); if (!matches) { continue; } @@ -32153,14 +32936,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_27); + matches = patternMatcher.getMatches(containers, name_24); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_27, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -32198,7 +32981,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 128 /* ComputedPropertyName */) { + else if (declaration.name.kind === 129 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -32219,7 +33002,7 @@ var ts; } return true; } - if (expression.kind === 156 /* PropertyAccessExpression */) { + if (expression.kind === 158 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -32232,7 +33015,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -32308,17 +33091,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 206 /* ModuleDeclaration */); + } while (current.kind === 208 /* ModuleDeclaration */); // fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -32329,21 +33112,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -32355,7 +33138,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -32364,21 +33147,21 @@ var ts; } } break; - case 153 /* BindingElement */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: childNodes.push(node); break; } @@ -32426,17 +33209,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -32447,12 +33230,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 201 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 203 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 180 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 182 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -32512,7 +33295,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -32520,36 +33303,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 139 /* CallSignature */: + case 140 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: var variableDeclarationNode; - var name_28; - if (node.kind === 153 /* BindingElement */) { - name_28 = node.name; + var name_25; + if (node.kind === 155 /* BindingElement */) { + name_25 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 199 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 201 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -32557,24 +33340,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_28 = node.name; + name_25 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); } - case 136 /* Constructor */: + case 137 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -32604,17 +33387,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: return createSourceFileItem(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return createClassItem(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return createEnumItem(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return createModuleItem(node); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -32626,7 +33409,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -32638,7 +33421,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 180 /* Block */) { + if (node.body && node.body.kind === 182 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -32659,7 +33442,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -32683,7 +33466,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -32692,13 +33475,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 206 /* ModuleDeclaration */) { + while (node.body.kind === 208 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 228 /* SourceFile */ + return node.kind === 230 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -33213,7 +33996,7 @@ var ts; var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { if (!isAllPunctuation(identifier, wordStart, i)) { @@ -33274,7 +34057,7 @@ var ts; // 3) HTMLDocument -> HTML, Document // // etc. - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); @@ -33493,7 +34276,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 158 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 160 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -33501,7 +34284,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 65 /* Identifier */ ? expression - : expression.kind === 156 /* PropertyAccessExpression */ + : expression.kind === 158 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -33534,7 +34317,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 158 /* CallExpression */ || node.parent.kind === 159 /* NewExpression */) { + if (node.parent.kind === 160 /* CallExpression */ || node.parent.kind === 161 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -33587,25 +34370,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 162 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 178 /* TemplateSpan */ && node.parent.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 180 /* TemplateSpan */ && node.parent.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -33723,7 +34506,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 172 /* TemplateExpression */) { + if (template.kind === 174 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -33732,7 +34515,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 228 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 230 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -33933,40 +34716,40 @@ var ts; return false; } switch (n.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 151 /* ObjectBindingPattern */: - case 146 /* TypeLiteral */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 208 /* CaseBlock */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 153 /* ObjectBindingPattern */: + case 148 /* TypeLiteral */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 210 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 159 /* NewExpression */: + case 161 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: - case 150 /* ParenthesizedType */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: + case 152 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -33976,63 +34759,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 184 /* IfStatement */: + case 186 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 154 /* ArrayLiteralExpression */: - case 152 /* ArrayBindingPattern */: - case 157 /* ElementAccessExpression */: - case 128 /* ComputedPropertyName */: - case 148 /* TupleType */: + case 156 /* ArrayLiteralExpression */: + case 154 /* ArrayBindingPattern */: + case 159 /* ElementAccessExpression */: + case 129 /* ComputedPropertyName */: + case 150 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 166 /* TypeOfExpression */: - case 165 /* DeleteExpression */: - case 167 /* VoidExpression */: - case 173 /* YieldExpression */: - case 174 /* SpreadElementExpression */: + case 168 /* TypeOfExpression */: + case 167 /* DeleteExpression */: + case 169 /* VoidExpression */: + case 175 /* YieldExpression */: + case 176 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -34088,7 +34871,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 251 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 253 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -34222,7 +35005,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 228 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 230 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -34266,17 +35049,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 142 /* TypeReference */ || node.kind === 158 /* CallExpression */) { + if (node.kind === 144 /* TypeReference */ || node.kind === 160 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 202 /* ClassDeclaration */ || node.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 204 /* ClassDeclaration */ || node.kind === 205 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 126 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 127 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -34331,7 +35114,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -34744,7 +35527,7 @@ var ts; if (this.tokensAreOnSameLine === undefined) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; }; @@ -34763,7 +35546,7 @@ var ts; FormattingContext.prototype.NodeIsOnOneLine = function (node) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); @@ -34923,7 +35706,7 @@ var ts; this.customContextChecks = funcs; } RuleOperationContext.prototype.IsAny = function () { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; }; RuleOperationContext.prototype.InContext = function (context) { if (this.IsAny()) { @@ -35029,7 +35812,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 121 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 122 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -35037,9 +35820,9 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 119 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118 /* ModuleKeyword */, 120 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 118 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 121 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 118 /* ModuleKeyword */, 119 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 122 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -35059,7 +35842,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 121 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 122 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110 /* YieldKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -35155,9 +35938,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_29 in o) { - if (o[name_29] === rule) { - return name_29; + for (var name_26 in o) { + if (o[name_26] === rule) { + return name_26; } } throw new Error("Unknown rule"); @@ -35166,36 +35949,37 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 187 /* ForStatement */; + return context.contextNode.kind === 189 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 143 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 153 /* BindingElement */: + case 155 /* BindingElement */: // equals in type X = ... - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: // equal in p = 0; - case 130 /* Parameter */: - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 131 /* Parameter */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 189 /* ForOfStatement */: - return context.currentTokenSpan.kind === 126 /* OfKeyword */ || context.nextTokenSpan.kind === 126 /* OfKeyword */; + case 191 /* ForOfStatement */: + return context.currentTokenSpan.kind === 127 /* OfKeyword */ || context.nextTokenSpan.kind === 127 /* OfKeyword */; } return false; }; @@ -35203,7 +35987,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 171 /* ConditionalExpression */; + return context.contextNode.kind === 173 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -35247,92 +36031,92 @@ var ts; return true; } switch (node.kind) { - case 180 /* Block */: - case 208 /* CaseBlock */: - case 155 /* ObjectLiteralExpression */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 210 /* CaseBlock */: + case 157 /* ObjectLiteralExpression */: + case 209 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 139 /* CallSignature */: - case 163 /* FunctionExpression */: - case 136 /* Constructor */: - case 164 /* ArrowFunction */: + case 140 /* CallSignature */: + case 165 /* FunctionExpression */: + case 137 /* Constructor */: + case 166 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 201 /* FunctionDeclaration */ || context.contextNode.kind === 163 /* FunctionExpression */; + return context.contextNode.kind === 203 /* FunctionDeclaration */ || context.contextNode.kind === 165 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 206 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 208 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 202 /* ClassDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 180 /* Block */: - case 224 /* CatchClause */: - case 207 /* ModuleBlock */: - case 194 /* SwitchStatement */: + case 204 /* ClassDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 182 /* Block */: + case 226 /* CatchClause */: + case 209 /* ModuleBlock */: + case 196 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 184 /* IfStatement */: - case 194 /* SwitchStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 197 /* TryStatement */: - case 185 /* DoStatement */: - case 193 /* WithStatement */: + case 186 /* IfStatement */: + case 196 /* SwitchStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 199 /* TryStatement */: + case 187 /* DoStatement */: + case 195 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 224 /* CatchClause */: + case 226 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 155 /* ObjectLiteralExpression */; + return context.contextNode.kind === 157 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 158 /* CallExpression */; + return context.contextNode.kind === 160 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 159 /* NewExpression */; + return context.contextNode.kind === 161 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -35356,38 +36140,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 131 /* Decorator */; + return node.kind === 132 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 200 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 202 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind != 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 206 /* ModuleDeclaration */; + return context.contextNode.kind === 208 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 146 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 148 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 142 /* TypeReference */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 144 /* TypeReference */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return true; default: return false; @@ -35398,10 +36182,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 167 /* VoidExpression */; + return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 169 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 173 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 175 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -35425,7 +36209,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 126 /* LastToken */ + 1; + this.mapRowLength = 127 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -35445,13 +36229,13 @@ var ts; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange != formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != formatting.Shared.TokenRange.Any; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); @@ -35518,7 +36302,7 @@ var ts; RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - ts.Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; this.rulesInsertionIndexBitmap = temp; @@ -35535,7 +36319,7 @@ var ts; }; RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { var position; - if (rule.Operation.Action == 1 /* Ignore */) { + if (rule.Operation.Action === 1 /* Ignore */) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; @@ -35610,7 +36394,7 @@ var ts; return [this.token]; }; TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue == this.token; + return tokenValue === this.token; }; return TokenSingleValueAccess; })(); @@ -35620,7 +36404,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 126 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 127 /* LastToken */; token++) { result.push(token); } return result; @@ -35662,9 +36446,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 126 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 127 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 126 /* OfKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 127 /* OfKeyword */, 117 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); @@ -35672,7 +36456,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 120 /* NumberKeyword */, 122 /* StringKeyword */, 113 /* BooleanKeyword */, 123 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 121 /* NumberKeyword */, 123 /* StringKeyword */, 113 /* BooleanKeyword */, 124 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -35711,6 +36495,7 @@ var ts; return this.rulesMap; }; RulesProvider.prototype.ensureUpToDate = function (options) { + // TODO: Should this be '==='? if (this.options == null || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); var rulesMap = formatting.RulesMap.create(activeRules); @@ -35875,17 +36660,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 180 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 228 /* SourceFile */: - case 180 /* Block */: - case 207 /* ModuleBlock */: + return body && body.kind === 182 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 230 /* SourceFile */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36058,9 +36843,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 228 /* SourceFile */ || - parent.kind === 221 /* CaseClause */ || - parent.kind === 222 /* DefaultClause */) { + parent.kind === 230 /* SourceFile */ || + parent.kind === 223 /* CaseClause */ || + parent.kind === 224 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -36096,19 +36881,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 202 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 203 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 201 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 205 /* EnumDeclaration */: return 205 /* EnumDeclaration */; - case 137 /* GetAccessor */: return 116 /* GetKeyword */; - case 138 /* SetAccessor */: return 121 /* SetKeyword */; - case 135 /* MethodDeclaration */: + case 204 /* ClassDeclaration */: return 69 /* ClassKeyword */; + case 205 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; + case 203 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; + case 207 /* EnumDeclaration */: return 207 /* EnumDeclaration */; + case 138 /* GetAccessor */: return 116 /* GetKeyword */; + case 139 /* SetAccessor */: return 122 /* SetKeyword */; + case 136 /* MethodDeclaration */: if (node.asteriskToken) { return 35 /* AsteriskToken */; } // fall-through - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: return node.name.kind; } } @@ -36241,7 +37026,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 131 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 132 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -36564,20 +37349,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 136 /* Constructor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 166 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -36585,8 +37370,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36594,7 +37379,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36693,7 +37478,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 170 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 172 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -36722,6 +37507,10 @@ var ts; if (actualIndentation !== -1 /* Unknown */) { return actualIndentation; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + options.IndentSize; + } previous = current; current = current.parent; } @@ -36764,6 +37553,10 @@ var ts; if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { @@ -36804,7 +37597,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 228 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 230 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -36837,7 +37630,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 184 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 186 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -36849,23 +37642,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return node.parent.properties; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return node.parent.elements; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: { + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -36876,8 +37669,8 @@ var ts; } break; } - case 159 /* NewExpression */: - case 158 /* CallExpression */: { + case 161 /* NewExpression */: + case 160 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -36901,6 +37694,44 @@ var ts; return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1 /* Unknown */; } } + function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { + // actual indentation should not be used when: + // - node is close parenthesis - this is the end of the expression + if (node.kind === 17 /* CloseParenToken */) { + return -1 /* Unknown */; + } + if (node.parent && (node.parent.kind === 160 /* CallExpression */ || + node.parent.kind === 161 /* NewExpression */) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1 /* Unknown */; + } + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + return -1 /* Unknown */; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); var node = list[index]; @@ -36956,28 +37787,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 154 /* ArrayLiteralExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 155 /* ObjectLiteralExpression */: - case 146 /* TypeLiteral */: - case 148 /* TupleType */: - case 208 /* CaseBlock */: - case 222 /* DefaultClause */: - case 221 /* CaseClause */: - case 162 /* ParenthesizedExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 181 /* VariableStatement */: - case 199 /* VariableDeclaration */: - case 215 /* ExportAssignment */: - case 192 /* ReturnStatement */: - case 171 /* ConditionalExpression */: - case 152 /* ArrayBindingPattern */: - case 151 /* ObjectBindingPattern */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 156 /* ArrayLiteralExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 157 /* ObjectLiteralExpression */: + case 148 /* TypeLiteral */: + case 150 /* TupleType */: + case 210 /* CaseBlock */: + case 224 /* DefaultClause */: + case 223 /* CaseClause */: + case 164 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 183 /* VariableStatement */: + case 201 /* VariableDeclaration */: + case 217 /* ExportAssignment */: + case 194 /* ReturnStatement */: + case 173 /* ConditionalExpression */: + case 154 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: return true; } return false; @@ -36987,22 +37818,22 @@ var ts; return true; } switch (parent) { - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - return child !== 180 /* Block */; + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + return child !== 182 /* Block */; default: return false; } @@ -37015,8 +37846,7 @@ var ts; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// @@ -37085,7 +37915,7 @@ var ts; return this.getEnd() - this.getStart(sourceFile); }; NodeObject.prototype.getFullWidth = function () { - return this.end - this.getFullStart(); + return this.end - this.pos; }; NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { return this.getStart(sourceFile) - this.pos; @@ -37107,7 +37937,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(251 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(253 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -37126,7 +37956,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 127 /* FirstNode */) { + if (this.kind >= 128 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -37171,7 +38001,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -37181,7 +38011,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -37234,7 +38064,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 130 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 131 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -37243,15 +38073,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 206 /* ModuleDeclaration */ && declaration.body.kind === 206 /* ModuleDeclaration */) { + if (declaration.kind === 208 /* ModuleDeclaration */ && declaration.body.kind === 208 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 206 /* ModuleDeclaration */ && declaration.parent.kind === 206 /* ModuleDeclaration */) { + while (declaration.kind === 208 /* ModuleDeclaration */ && declaration.parent.kind === 208 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -37590,9 +38420,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -37612,9 +38442,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -37634,60 +38464,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 146 /* TypeLiteral */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 148 /* TypeLiteral */: addDeclaration(node); // fall through - case 136 /* Constructor */: - case 181 /* VariableStatement */: - case 200 /* VariableDeclarationList */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 207 /* ModuleBlock */: + case 137 /* Constructor */: + case 183 /* VariableStatement */: + case 202 /* VariableDeclarationList */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 209 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 130 /* Parameter */: + case 131 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: addDeclaration(node); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37699,7 +38529,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -37900,16 +38730,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 163 /* FunctionExpression */) { + if (declaration.kind === 165 /* FunctionExpression */) { return true; } - if (declaration.kind !== 199 /* VariableDeclaration */ && declaration.kind !== 201 /* FunctionDeclaration */) { + if (declaration.kind !== 201 /* VariableDeclaration */ && declaration.kind !== 203 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_8.kind === 228 /* SourceFile */ || parent_8.kind === 207 /* ModuleBlock */) { + if (parent_9.kind === 230 /* SourceFile */ || parent_9.kind === 209 /* ModuleBlock */) { return false; } } @@ -37953,9 +38783,8 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = {}; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); for (var _i = 0; _i < rootFileNames.length; _i++) { @@ -37968,9 +38797,6 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.normalizeFileName = function (fileName) { - return this.getCanonicalFileName(ts.normalizeSlashes(fileName)); - }; HostCache.prototype.createEntry = function (fileName) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -37981,13 +38807,14 @@ var ts; scriptSnapshot: scriptSnapshot }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; }; HostCache.prototype.getEntry = function (fileName) { - return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); }; HostCache.prototype.contains = function (fileName) { - return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); }; HostCache.prototype.getOrCreateEntry = function (fileName) { if (this.contains(fileName)) { @@ -37996,12 +38823,10 @@ var ts; return this.createEntry(fileName); }; HostCache.prototype.getRootFileNames = function () { - var _this = this; var fileNames = []; - ts.forEachKey(this.fileNameToEntry, function (key) { - var entry = _this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); } }); return fileNames; @@ -38061,7 +38886,7 @@ var ts; * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics) { + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. @@ -38075,9 +38900,8 @@ var ts; // Parse var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - // Store syntactic diagnostics - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics); + if (moduleName) { + sourceFile.moduleName = moduleName; } var newLine = ts.getNewLineCharacter(options); // Output @@ -38096,9 +38920,8 @@ var ts; getNewLine: function () { return newLine; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics()); - } + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); @@ -38158,10 +38981,16 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createDocumentRegistry() { + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() } @@ -38169,7 +38998,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); } return bucket; } @@ -38178,7 +39007,7 @@ var ts; var entries = ts.lookUp(buckets, name); var sourceFiles = []; for (var i in entries) { - var entry = entries[i]; + var entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -38201,16 +39030,17 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -38233,11 +39063,11 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.remove(fileName); } } return { @@ -38300,7 +39130,7 @@ var ts; else { if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -38310,7 +39140,7 @@ var ts; } else if (token === 53 /* EqualsToken */) { token = scanner.scan(); - if (token === 119 /* RequireKeyword */) { + if (token === 120 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -38339,7 +39169,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -38355,7 +39185,7 @@ var ts; token = scanner.scan(); if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -38378,7 +39208,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -38390,7 +39220,7 @@ var ts; } else if (token === 35 /* AsteriskToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -38413,7 +39243,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 195 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 197 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -38422,12 +39252,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 /* Identifier */ && - (node.parent.kind === 191 /* BreakStatement */ || node.parent.kind === 190 /* ContinueStatement */) && + (node.parent.kind === 193 /* BreakStatement */ || node.parent.kind === 192 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 /* Identifier */ && - node.parent.kind === 195 /* LabeledStatement */ && + node.parent.kind === 197 /* LabeledStatement */ && node.parent.label === node; } /** @@ -38435,7 +39265,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 195 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 197 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -38446,25 +39276,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 206 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 208 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 /* Identifier */ && @@ -38473,22 +39303,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 225 /* PropertyAssignment */ || node.parent.kind === 226 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 227 /* PropertyAssignment */ || node.parent.kind === 228 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 206 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 208 /* ModuleDeclaration */: return node.parent.name === node; - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -38547,7 +39377,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 126 /* LastKeyword */; i++) { + for (var i = 66 /* FirstKeyword */; i <= 127 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -38562,17 +39392,17 @@ var ts; return undefined; } switch (node.kind) { - case 228 /* SourceFile */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: return node; } } @@ -38580,38 +39410,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 206 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 202 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 203 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 204 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 205 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 199 /* VariableDeclaration */: + case 208 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 204 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 205 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 206 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 207 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 201 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 201 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 137 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 138 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 138 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 139 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 141 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 140 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 139 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 136 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 129 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 227 /* EnumMember */: return ScriptElementKind.variableElement; - case 130 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 211 /* ImportClause */: - case 218 /* ExportSpecifier */: - case 212 /* NamespaceImport */: + case 142 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 141 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 140 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 137 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 130 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 229 /* EnumMember */: return ScriptElementKind.variableElement; + case 131 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 220 /* ExportSpecifier */: + case 214 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -38634,9 +39464,7 @@ var ts; host.log(message); } } - function getCanonicalFileName(fileName) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { fileName = ts.normalizeSlashes(fileName); var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); @@ -38827,44 +39655,44 @@ var ts; return false; } switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 102 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -38872,20 +39700,20 @@ var ts; return true; } break; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -38893,7 +39721,7 @@ var ts; return true; } break; - case 130 /* Parameter */: + case 131 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -38909,17 +39737,17 @@ var ts; return true; } break; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 131 /* Decorator */: + case 132 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -38964,7 +39792,7 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } /// Completion function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { @@ -39053,11 +39881,11 @@ var ts; // visible symbols in the scope, and the node is the current location. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 156 /* PropertyAccessExpression */) { + if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 158 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 127 /* QualifiedName */) { + else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 128 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -39084,7 +39912,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */) { + if (node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -39142,13 +39970,13 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 211 /* ImportClause */)) { + else if (ts.getAncestor(contextToken, 213 /* ImportClause */)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 210 /* ImportDeclaration */); + var importDeclaration = ts.getAncestor(contextToken, 212 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); var exports; if (importDeclaration.moduleSpecifier) { @@ -39227,7 +40055,7 @@ var ts; // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 213 /* NamedImports */; + return node.parent.kind === 215 /* NamedImports */; } } return false; @@ -39237,38 +40065,38 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 158 /* CallExpression */ // func( a, | - || containingNodeKind === 136 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 159 /* NewExpression */ // new C(a, | - || containingNodeKind === 154 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 170 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 143 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 160 /* CallExpression */ // func( a, | + || containingNodeKind === 137 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === 161 /* NewExpression */ // new C(a, | + || containingNodeKind === 156 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 172 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 145 /* FunctionType */; // var x: (s: string, list| case 16 /* OpenParenToken */: - return containingNodeKind === 158 /* CallExpression */ // func( | - || containingNodeKind === 136 /* Constructor */ // constructor( | - || containingNodeKind === 159 /* NewExpression */ // new C(a| - || containingNodeKind === 162 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 150 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + return containingNodeKind === 160 /* CallExpression */ // func( | + || containingNodeKind === 137 /* Constructor */ // constructor( | + || containingNodeKind === 161 /* NewExpression */ // new C(a| + || containingNodeKind === 164 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 152 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument case 18 /* OpenBracketToken */: - return containingNodeKind === 154 /* ArrayLiteralExpression */; // [ | - case 117 /* ModuleKeyword */: // module | - case 118 /* NamespaceKeyword */: + return containingNodeKind === 156 /* ArrayLiteralExpression */; // [ | + case 118 /* ModuleKeyword */: // module | + case 119 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 206 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 208 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 202 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 204 /* ClassDeclaration */; // class A{ | case 53 /* EqualsToken */: - return containingNodeKind === 199 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 170 /* BinaryExpression */; // x = a| + return containingNodeKind === 201 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 172 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 172 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 174 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 178 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 180 /* TemplateSpan */; // `aa ${10} dd ${| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 134 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -39303,12 +40131,12 @@ var ts; function getContainingObjectLiteralApplicableForCompletion(previousToken) { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var parent_9 = previousToken.parent; + var parent_10 = previousToken.parent; switch (previousToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_9 && parent_9.kind === 155 /* ObjectLiteralExpression */) { - return parent_9; + if (parent_10 && parent_10.kind === 157 /* ObjectLiteralExpression */) { + return parent_10; } break; } @@ -39317,16 +40145,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return true; } return false; @@ -39336,63 +40164,63 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 199 /* VariableDeclaration */ || - containingNodeKind === 200 /* VariableDeclarationList */ || - containingNodeKind === 181 /* VariableStatement */ || - containingNodeKind === 205 /* EnumDeclaration */ || + return containingNodeKind === 201 /* VariableDeclaration */ || + containingNodeKind === 202 /* VariableDeclarationList */ || + containingNodeKind === 183 /* VariableStatement */ || + containingNodeKind === 207 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* ArrayBindingPattern */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x, y| + containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 154 /* ArrayBindingPattern */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x, y| case 20 /* DotToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [.| case 51 /* ColonToken */: - return containingNodeKind === 153 /* BindingElement */; // var {x :html| + return containingNodeKind === 155 /* BindingElement */; // var {x :html| case 18 /* OpenBracketToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [x| case 16 /* OpenParenToken */: - return containingNodeKind === 224 /* CatchClause */ || + return containingNodeKind === 226 /* CatchClause */ || isFunction(containingNodeKind); case 14 /* OpenBraceToken */: - return containingNodeKind === 205 /* EnumDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 146 /* TypeLiteral */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x| + return containingNodeKind === 207 /* EnumDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 148 /* TypeLiteral */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x| case 22 /* SemicolonToken */: - return containingNodeKind === 132 /* PropertySignature */ && + return containingNodeKind === 133 /* PropertySignature */ && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 203 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 146 /* TypeLiteral */); // let x : { a; | + (previousToken.parent.parent.kind === 205 /* InterfaceDeclaration */ || + previousToken.parent.parent.kind === 148 /* TypeLiteral */); // let x : { a; | case 24 /* LessThanToken */: - return containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || + return containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || isFunction(containingNodeKind); case 109 /* StaticKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; + return containingNodeKind === 134 /* PropertyDeclaration */; case 21 /* DotDotDotToken */: - return containingNodeKind === 130 /* Parameter */ || - containingNodeKind === 136 /* Constructor */ || + return containingNodeKind === 131 /* Parameter */ || + containingNodeKind === 137 /* Constructor */ || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 152 /* ArrayBindingPattern */); // var [...z| + previousToken.parent.parent.kind === 154 /* ArrayBindingPattern */); // var [...z| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 130 /* Parameter */; + return containingNodeKind === 131 /* Parameter */; case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: case 103 /* InterfaceKeyword */: case 83 /* FunctionKeyword */: case 98 /* VarKeyword */: case 116 /* GetKeyword */: - case 121 /* SetKeyword */: + case 122 /* SetKeyword */: case 85 /* ImportKeyword */: case 104 /* LetKeyword */: case 70 /* ConstKeyword */: case 110 /* YieldKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -39424,7 +40252,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 213 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 215 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -39441,7 +40269,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 225 /* PropertyAssignment */ && m.kind !== 226 /* ShorthandPropertyAssignment */) { + if (m.kind !== 227 /* PropertyAssignment */ && m.kind !== 228 /* ShorthandPropertyAssignment */) { // Ignore omitted expressions for missing members in the object literal return; } @@ -39491,10 +40319,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_30 in nameTable) { - if (!allNames[name_30]) { - allNames[name_30] = name_30; - var displayName = getCompletionEntryDisplayName(name_30, target, true); + for (var name_27 in nameTable) { + if (!allNames[name_27]) { + allNames[name_27] = name_27; + var displayName = getCompletionEntryDisplayName(name_27, target, true); if (displayName) { var entry = { name: displayName, @@ -39693,7 +40521,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 156 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 158 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -39702,7 +40530,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 158 /* CallExpression */ || location.kind === 159 /* NewExpression */) { + if (location.kind === 160 /* CallExpression */ || location.kind === 161 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -39715,7 +40543,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 159 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 161 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -39767,24 +40595,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 136 /* Constructor */)) { + (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 137 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 136 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 137 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 136 /* Constructor */) { + if (functionDeclaration.kind === 137 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -39807,7 +40635,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(124 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(125 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -39827,9 +40655,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 206 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 208 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 118 /* NamespaceKeyword */ : 117 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 119 /* NamespaceKeyword */ : 118 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -39850,13 +40678,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 140 /* ConstructSignature */) { + if (signatureDeclaration.kind === 141 /* ConstructSignature */) { displayParts.push(ts.keywordPart(88 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 139 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 140 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -39865,7 +40693,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 227 /* EnumMember */) { + if (declaration.kind === 229 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -39881,13 +40709,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 209 /* ImportEqualsDeclaration */) { + if (declaration.kind === 211 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(119 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(120 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -40014,8 +40842,8 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position @@ -40073,7 +40901,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 204 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -40089,8 +40917,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 136 /* Constructor */) || - (!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 137 /* Constructor */) || + (!selectConstructors && (d.kind === 203 /* FunctionDeclaration */ || d.kind === 136 /* MethodDeclaration */ || d.kind === 135 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -40159,7 +40987,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 226 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 228 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -40193,7 +41021,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -40288,74 +41116,74 @@ var ts; switch (node.kind) { case 84 /* IfKeyword */: case 76 /* ElseKeyword */: - if (hasKind(node.parent, 184 /* IfStatement */)) { + if (hasKind(node.parent, 186 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 192 /* ReturnStatement */)) { + if (hasKind(node.parent, 194 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 196 /* ThrowStatement */)) { + if (hasKind(node.parent, 198 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 197 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96 /* TryKeyword */: case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 197 /* TryStatement */)) { + if (hasKind(parent(node), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 194 /* SwitchStatement */)) { + if (hasKind(node.parent, 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67 /* CaseKeyword */: case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 194 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66 /* BreakKeyword */: case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 191 /* BreakStatement */) || hasKind(node.parent, 190 /* ContinueStatement */)) { + if (hasKind(node.parent, 193 /* BreakStatement */) || hasKind(node.parent, 192 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82 /* ForKeyword */: - if (hasKind(node.parent, 187 /* ForStatement */) || - hasKind(node.parent, 188 /* ForInStatement */) || - hasKind(node.parent, 189 /* ForOfStatement */)) { + if (hasKind(node.parent, 189 /* ForStatement */) || + hasKind(node.parent, 190 /* ForInStatement */) || + hasKind(node.parent, 191 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100 /* WhileKeyword */: case 75 /* DoKeyword */: - if (hasKind(node.parent, 186 /* WhileStatement */) || hasKind(node.parent, 185 /* DoStatement */)) { + if (hasKind(node.parent, 188 /* WhileStatement */) || hasKind(node.parent, 187 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 136 /* Constructor */)) { + if (hasKind(node.parent, 137 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 116 /* GetKeyword */: - case 121 /* SetKeyword */: - if (hasKind(node.parent, 137 /* GetAccessor */) || hasKind(node.parent, 138 /* SetAccessor */)) { + case 122 /* SetKeyword */: + if (hasKind(node.parent, 138 /* GetAccessor */) || hasKind(node.parent, 139 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 181 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 183 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -40371,10 +41199,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 196 /* ThrowStatement */) { + if (node.kind === 198 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 197 /* TryStatement */) { + else if (node.kind === 199 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -40402,19 +41230,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_10 = child.parent; - if (ts.isFunctionBlock(parent_10) || parent_10.kind === 228 /* SourceFile */) { - return parent_10; + var parent_11 = child.parent; + if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230 /* SourceFile */) { + return parent_11; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_10.kind === 197 /* TryStatement */) { - var tryStatement = parent_10; + if (parent_11.kind === 199 /* TryStatement */) { + var tryStatement = parent_11; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_10; + child = parent_11; } return undefined; } @@ -40423,7 +41251,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 191 /* BreakStatement */ || node.kind === 190 /* ContinueStatement */) { + if (node.kind === 193 /* BreakStatement */ || node.kind === 192 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -40437,25 +41265,25 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 194 /* SwitchStatement */: - if (statement.kind === 190 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 196 /* SwitchStatement */: + if (statement.kind === 192 /* ContinueStatement */) { continue; } // Fall through. - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -40467,18 +41295,18 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 130 /* Parameter */ && hasKind(container, 136 /* Constructor */)))) { + if (!(container.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 131 /* Parameter */ && hasKind(container, 137 /* Constructor */)))) { return undefined; } } else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 202 /* ClassDeclaration */) { + if (container.kind !== 204 /* ClassDeclaration */) { return undefined; } } else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 207 /* ModuleBlock */ || container.kind === 228 /* SourceFile */)) { + if (!(container.kind === 209 /* ModuleBlock */ || container.kind === 230 /* SourceFile */)) { return undefined; } } @@ -40490,20 +41318,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 207 /* ModuleBlock */: - case 228 /* SourceFile */: + case 209 /* ModuleBlock */: + case 230 /* SourceFile */: nodes = container.statements; break; - case 136 /* Constructor */: + case 137 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -40551,13 +41379,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 139 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 121 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 122 /* SetKeyword */); }); } } } @@ -40575,7 +41403,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 185 /* DoStatement */) { + if (loopNode.kind === 187 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { @@ -40596,13 +41424,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -40656,7 +41484,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 180 /* Block */))) { + if (!(func && hasKind(func.body, 182 /* Block */))) { return undefined; } var keywords = []; @@ -40672,7 +41500,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 184 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 186 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -40685,7 +41513,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 184 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 186 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -40864,17 +41692,17 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 214 /* ImportSpecifier */ || location.parent.kind === 218 /* ExportSpecifier */) && + (location.parent.kind === 216 /* ImportSpecifier */ || location.parent.kind === 220 /* ExportSpecifier */) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 218 /* ExportSpecifier */; + return declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 220 /* ExportSpecifier */; }); } function getDeclaredName(symbol, location) { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40901,7 +41729,7 @@ var ts; return location.getText(); } // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40925,7 +41753,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 202 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 204 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -40951,7 +41779,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -41139,13 +41967,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -41177,27 +42005,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -41206,7 +42034,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 228 /* SourceFile */) { + if (searchSpaceNode.kind === 230 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -41237,27 +42065,27 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 228 /* SourceFile */: - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + case 230 /* SourceFile */: + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -41311,11 +42139,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 202 /* ClassDeclaration */) { + if (declaration.kind === 204 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 203 /* InterfaceDeclaration */) { + else if (declaration.kind === 205 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -41376,19 +42204,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_31 = node.text; + var name_28 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_31); + var unionProperty = contextualType.getProperty(name_28); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_31); + var symbol = t.getProperty(name_28); if (symbol) { result_4.push(symbol); } @@ -41397,7 +42225,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_31); + var symbol_1 = contextualType.getProperty(name_28); if (symbol_1) { return [symbol_1]; } @@ -41455,10 +42283,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 169 /* PostfixUnaryExpression */ || parent.kind === 168 /* PrefixUnaryExpression */) { + if (parent.kind === 171 /* PostfixUnaryExpression */ || parent.kind === 170 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 170 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 172 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; } @@ -41492,33 +42320,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 224 /* CatchClause */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 226 /* CatchClause */: return 1 /* Value */; - case 129 /* TypeParameter */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 146 /* TypeLiteral */: + case 130 /* TypeParameter */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 148 /* TypeLiteral */: return 2 /* Type */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -41528,15 +42356,15 @@ var ts; else { return 4 /* Namespace */; } - case 213 /* NamedImports */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 210 /* ImportDeclaration */: - case 215 /* ExportAssignment */: - case 216 /* ExportDeclaration */: + case 215 /* NamedImports */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 212 /* ImportDeclaration */: + case 217 /* ExportAssignment */: + case 218 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 228 /* SourceFile */: + case 230 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -41546,7 +42374,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 142 /* TypeReference */ || node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent.kind === 144 /* TypeReference */ || + (node.parent.kind === 179 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -41554,32 +42383,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 156 /* PropertyAccessExpression */) { + if (root.parent.kind === 158 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 158 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 223 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 179 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 225 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 202 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 203 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 204 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || + (decl.kind === 205 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 127 /* QualifiedName */) { - while (root.parent && root.parent.kind === 127 /* QualifiedName */) { + if (root.parent.kind === 128 /* QualifiedName */) { + while (root.parent && root.parent.kind === 128 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 142 /* TypeReference */ && !isLastClause; + return root.parent.kind === 144 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 127 /* QualifiedName */) { + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -41589,15 +42418,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 127 /* QualifiedName */ && + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 209 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 211 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent.kind === 217 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -41637,8 +42466,8 @@ var ts; return; } switch (node.kind) { - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 8 /* StringLiteral */: case 80 /* FalseKeyword */: case 95 /* TrueKeyword */: @@ -41661,7 +42490,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 206 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 208 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -41695,6 +42524,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; + var classifiableNames = program.getClassifiableNames(); processNode(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; function pushClassification(start, length, type) { @@ -41704,6 +42534,9 @@ var ts; } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); + if ((flags & 788448 /* Classifiable */) === 0 /* None */) { + return; + } if (flags & 32 /* Class */) { return 11 /* className */; } @@ -41736,19 +42569,26 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 208 /* ModuleDeclaration */ && + ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } } function processNode(node) { // Only walk into nodes that intersect the requested span. - if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 65 /* Identifier */ && node.getWidth() > 0) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + if (node.kind === 65 /* Identifier */ && !ts.nodeIsMissing(node)) { + var identifier = node; + // Only bother calling into the typechecker if this is an identifier that + // could possibly resolve to a type name. This makes classification run + // in a third of the time it would normally take. + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } } @@ -41795,6 +42635,8 @@ var ts; function getEncodedSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var spanStart = span.start; + var spanLength = span.length; // Make a scanner we can get trivia from. var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); @@ -41806,42 +42648,47 @@ var ts; result.push(length); result.push(type); } - function classifyLeadingTrivia(token) { - var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); - if (tokenStart === token.pos) { - return; - } - // token has trivia. Classify them appropriately. + function classifyLeadingTriviaAndGetTokenStart(token) { triviaScanner.setTextPos(token.pos); while (true) { var start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; // The moment we get something that isn't trivia, then stop processing. if (!ts.isTrivia(kind)) { - return; + return start; + } + // Don't bother with newlines/whitespace. + if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { + continue; } // Only bother with the trivia if it at least intersects the span of interest. - if (ts.textSpanIntersectsWith(span, start, width)) { - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + if (kind === 6 /* ConflictMarkerTrivia */) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + pushClassification(start, width, 1 /* comment */); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); - continue; - } - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 61 /* equals */); - classifyDisabledMergeCode(text, start, end); - } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + ts.Debug.assert(ch === 61 /* equals */); + classifyDisabledMergeCode(text, start, end); } } } @@ -41875,16 +42722,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -41942,11 +42789,16 @@ var ts; } } function classifyToken(token) { - classifyLeadingTrivia(token); - if (token.getWidth() > 0) { + if (ts.nodeIsMissing(token)) { + return; + } + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { var type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -41970,16 +42822,16 @@ var ts; if (token) { if (tokenKind === 53 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 199 /* VariableDeclaration */ || - token.parent.kind === 133 /* PropertyDeclaration */ || - token.parent.kind === 130 /* Parameter */) { + if (token.parent.kind === 201 /* VariableDeclaration */ || + token.parent.kind === 134 /* PropertyDeclaration */ || + token.parent.kind === 131 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 170 /* BinaryExpression */ || - token.parent.kind === 168 /* PrefixUnaryExpression */ || - token.parent.kind === 169 /* PostfixUnaryExpression */ || - token.parent.kind === 171 /* ConditionalExpression */) { + if (token.parent.kind === 172 /* BinaryExpression */ || + token.parent.kind === 170 /* PrefixUnaryExpression */ || + token.parent.kind === 171 /* PostfixUnaryExpression */ || + token.parent.kind === 173 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -42002,32 +42854,32 @@ var ts; else if (tokenKind === 65 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 130 /* Parameter */: + case 131 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -42042,10 +42894,10 @@ var ts; return; } // Ignore nodes that don't intersect the original span to classify. - if (ts.textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { var children = element.getChildren(sourceFile); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; if (ts.isToken(child)) { classifyToken(child); } @@ -42372,7 +43224,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 220 /* ExternalModuleReference */ || + node.parent.kind === 222 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -42385,7 +43237,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 157 /* ElementAccessExpression */ && + node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -42433,7 +43285,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 121 /* SetKeyword */ || + keyword2 === 122 /* SetKeyword */ || keyword2 === 114 /* ConstructorKeyword */ || keyword2 === 109 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -42592,10 +43444,10 @@ var ts; angleBracketStack--; } else if (token === 112 /* AnyKeyword */ || - token === 122 /* StringKeyword */ || - token === 120 /* NumberKeyword */ || + token === 123 /* StringKeyword */ || + token === 121 /* NumberKeyword */ || token === 113 /* BooleanKeyword */ || - token === 123 /* SymbolKeyword */) { + token === 124 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -42766,7 +43618,7 @@ var ts; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 126 /* LastKeyword */; + return token >= 66 /* FirstKeyword */ && token <= 127 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -42824,7 +43676,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 228 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 230 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -42894,125 +43746,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 187 /* ForStatement */) { + if (node.parent.kind === 189 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 170 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 172 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind == 164 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 199 /* VariableDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 201 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return spanInVariableDeclaration(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return spanInParameterDeclaration(node); - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: return spanInBlock(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInBlock(node.block); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 184 /* IfStatement */: + case 186 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInForStatement(node); - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 197 /* TryStatement */: + case 199 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: // span on complete node return textSpan(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -43042,11 +43894,11 @@ var ts; return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 225 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 227 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 161 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 163 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -43059,12 +43911,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 188 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 190 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -43118,7 +43970,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 202 /* ClassDeclaration */ && functionDeclaration.kind !== 136 /* Constructor */); + (functionDeclaration.parent.kind === 204 /* ClassDeclaration */ && functionDeclaration.kind !== 137 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -43141,18 +43993,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 186 /* WhileStatement */: - case 184 /* IfStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 186 /* IfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -43160,7 +44012,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -43180,13 +44032,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -43194,25 +44046,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 205 /* EnumDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -43226,7 +44078,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -43236,17 +44088,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - case 187 /* ForStatement */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + case 189 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -43257,19 +44109,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 225 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 227 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 161 /* TypeAssertionExpression */) { + if (node.parent.kind === 163 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -43320,6 +44172,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + // TODO: should this be '==='? if (encoded == null) { return null; } @@ -43331,12 +44184,18 @@ var ts; var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; } LanguageServiceShimHostAdapter.prototype.log = function (s) { - this.shimHost.log(s); + if (this.loggingEnabled) { + this.shimHost.log(s); + } }; LanguageServiceShimHostAdapter.prototype.trace = function (s) { - this.shimHost.trace(s); + if (this.tracingEnabled) { + this.shimHost.trace(s); + } }; LanguageServiceShimHostAdapter.prototype.error = function (s) { this.shimHost.error(s); @@ -43348,8 +44207,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; @@ -43415,13 +44278,13 @@ var ts; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, noPerfLogging) { - if (!noPerfLogging) { + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { logger.log(actionDescription); var start = Date.now(); } var result = action(); - if (!noPerfLogging) { + if (logPerformance) { var end = Date.now(); logger.log(actionDescription + " completed in " + (end - start) + " msec"); if (typeof (result) === "string") { @@ -43434,9 +44297,9 @@ var ts; } return result; } - function forwardJSONCall(logger, actionDescription, action, noPerfLogging) { + function forwardJSONCall(logger, actionDescription, action, logPerformance) { try { - var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); return JSON.stringify({ result: result }); } catch (err) { @@ -43478,10 +44341,11 @@ var ts; _super.call(this, factory); this.host = host; this.languageService = languageService; + this.logPerformance = false; this.logger = this.host; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; /// DISPOSE /** @@ -43788,12 +44652,12 @@ var ts; function ClassifierShimObject(factory, logger) { _super.call(this, factory); this.logger = logger; + this.logPerformance = false; this.classifier = ts.createClassifier(); } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, - /*noPerfLogging:*/ true); + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { @@ -43815,9 +44679,10 @@ var ts; _super.call(this, factory); this.logger = logger; this.host = host; + this.logPerformance = false; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { @@ -43874,7 +44739,6 @@ var ts; var TypeScriptServicesFactory = (function () { function TypeScriptServicesFactory() { this._shims = []; - this.documentRegistry = ts.createDocumentRegistry(); } /* * Returns script API version. @@ -43884,6 +44748,9 @@ var ts; }; TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + } var hostAdapter = new LanguageServiceShimHostAdapter(host); var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService); diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index 9a153ade4b1..70e4f42e1ef 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -13,10 +13,17 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -declare module ts { +declare namespace ts { interface Map { [index: string]: T; } + interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + remove(fileName: string): void; + forEachValue(f: (v: T) => void): void; + } interface TextRange { pos: number; end: number; @@ -139,156 +146,158 @@ declare module ts { ConstructorKeyword = 114, DeclareKeyword = 115, GetKeyword = 116, - ModuleKeyword = 117, - NamespaceKeyword = 118, - RequireKeyword = 119, - NumberKeyword = 120, - SetKeyword = 121, - StringKeyword = 122, - SymbolKeyword = 123, - TypeKeyword = 124, - FromKeyword = 125, - OfKeyword = 126, - QualifiedName = 127, - ComputedPropertyName = 128, - TypeParameter = 129, - Parameter = 130, - Decorator = 131, - PropertySignature = 132, - PropertyDeclaration = 133, - MethodSignature = 134, - MethodDeclaration = 135, - Constructor = 136, - GetAccessor = 137, - SetAccessor = 138, - CallSignature = 139, - ConstructSignature = 140, - IndexSignature = 141, - TypeReference = 142, - FunctionType = 143, - ConstructorType = 144, - TypeQuery = 145, - TypeLiteral = 146, - ArrayType = 147, - TupleType = 148, - UnionType = 149, - ParenthesizedType = 150, - ObjectBindingPattern = 151, - ArrayBindingPattern = 152, - BindingElement = 153, - ArrayLiteralExpression = 154, - ObjectLiteralExpression = 155, - PropertyAccessExpression = 156, - ElementAccessExpression = 157, - CallExpression = 158, - NewExpression = 159, - TaggedTemplateExpression = 160, - TypeAssertionExpression = 161, - ParenthesizedExpression = 162, - FunctionExpression = 163, - ArrowFunction = 164, - DeleteExpression = 165, - TypeOfExpression = 166, - VoidExpression = 167, - PrefixUnaryExpression = 168, - PostfixUnaryExpression = 169, - BinaryExpression = 170, - ConditionalExpression = 171, - TemplateExpression = 172, - YieldExpression = 173, - SpreadElementExpression = 174, - ClassExpression = 175, - OmittedExpression = 176, - ExpressionWithTypeArguments = 177, - TemplateSpan = 178, - SemicolonClassElement = 179, - Block = 180, - VariableStatement = 181, - EmptyStatement = 182, - ExpressionStatement = 183, - IfStatement = 184, - DoStatement = 185, - WhileStatement = 186, - ForStatement = 187, - ForInStatement = 188, - ForOfStatement = 189, - ContinueStatement = 190, - BreakStatement = 191, - ReturnStatement = 192, - WithStatement = 193, - SwitchStatement = 194, - LabeledStatement = 195, - ThrowStatement = 196, - TryStatement = 197, - DebuggerStatement = 198, - VariableDeclaration = 199, - VariableDeclarationList = 200, - FunctionDeclaration = 201, - ClassDeclaration = 202, - InterfaceDeclaration = 203, - TypeAliasDeclaration = 204, - EnumDeclaration = 205, - ModuleDeclaration = 206, - ModuleBlock = 207, - CaseBlock = 208, - ImportEqualsDeclaration = 209, - ImportDeclaration = 210, - ImportClause = 211, - NamespaceImport = 212, - NamedImports = 213, - ImportSpecifier = 214, - ExportAssignment = 215, - ExportDeclaration = 216, - NamedExports = 217, - ExportSpecifier = 218, - MissingDeclaration = 219, - ExternalModuleReference = 220, - CaseClause = 221, - DefaultClause = 222, - HeritageClause = 223, - CatchClause = 224, - PropertyAssignment = 225, - ShorthandPropertyAssignment = 226, - EnumMember = 227, - SourceFile = 228, - JSDocTypeExpression = 229, - JSDocAllType = 230, - JSDocUnknownType = 231, - JSDocArrayType = 232, - JSDocUnionType = 233, - JSDocTupleType = 234, - JSDocNullableType = 235, - JSDocNonNullableType = 236, - JSDocRecordType = 237, - JSDocRecordMember = 238, - JSDocTypeReference = 239, - JSDocOptionalType = 240, - JSDocFunctionType = 241, - JSDocVariadicType = 242, - JSDocConstructorType = 243, - JSDocThisType = 244, - JSDocComment = 245, - JSDocTag = 246, - JSDocParameterTag = 247, - JSDocReturnTag = 248, - JSDocTypeTag = 249, - JSDocTemplateTag = 250, - SyntaxList = 251, - Count = 252, + IsKeyword = 117, + ModuleKeyword = 118, + NamespaceKeyword = 119, + RequireKeyword = 120, + NumberKeyword = 121, + SetKeyword = 122, + StringKeyword = 123, + SymbolKeyword = 124, + TypeKeyword = 125, + FromKeyword = 126, + OfKeyword = 127, + QualifiedName = 128, + ComputedPropertyName = 129, + TypeParameter = 130, + Parameter = 131, + Decorator = 132, + PropertySignature = 133, + PropertyDeclaration = 134, + MethodSignature = 135, + MethodDeclaration = 136, + Constructor = 137, + GetAccessor = 138, + SetAccessor = 139, + CallSignature = 140, + ConstructSignature = 141, + IndexSignature = 142, + TypePredicate = 143, + TypeReference = 144, + FunctionType = 145, + ConstructorType = 146, + TypeQuery = 147, + TypeLiteral = 148, + ArrayType = 149, + TupleType = 150, + UnionType = 151, + ParenthesizedType = 152, + ObjectBindingPattern = 153, + ArrayBindingPattern = 154, + BindingElement = 155, + ArrayLiteralExpression = 156, + ObjectLiteralExpression = 157, + PropertyAccessExpression = 158, + ElementAccessExpression = 159, + CallExpression = 160, + NewExpression = 161, + TaggedTemplateExpression = 162, + TypeAssertionExpression = 163, + ParenthesizedExpression = 164, + FunctionExpression = 165, + ArrowFunction = 166, + DeleteExpression = 167, + TypeOfExpression = 168, + VoidExpression = 169, + PrefixUnaryExpression = 170, + PostfixUnaryExpression = 171, + BinaryExpression = 172, + ConditionalExpression = 173, + TemplateExpression = 174, + YieldExpression = 175, + SpreadElementExpression = 176, + ClassExpression = 177, + OmittedExpression = 178, + ExpressionWithTypeArguments = 179, + TemplateSpan = 180, + SemicolonClassElement = 181, + Block = 182, + VariableStatement = 183, + EmptyStatement = 184, + ExpressionStatement = 185, + IfStatement = 186, + DoStatement = 187, + WhileStatement = 188, + ForStatement = 189, + ForInStatement = 190, + ForOfStatement = 191, + ContinueStatement = 192, + BreakStatement = 193, + ReturnStatement = 194, + WithStatement = 195, + SwitchStatement = 196, + LabeledStatement = 197, + ThrowStatement = 198, + TryStatement = 199, + DebuggerStatement = 200, + VariableDeclaration = 201, + VariableDeclarationList = 202, + FunctionDeclaration = 203, + ClassDeclaration = 204, + InterfaceDeclaration = 205, + TypeAliasDeclaration = 206, + EnumDeclaration = 207, + ModuleDeclaration = 208, + ModuleBlock = 209, + CaseBlock = 210, + ImportEqualsDeclaration = 211, + ImportDeclaration = 212, + ImportClause = 213, + NamespaceImport = 214, + NamedImports = 215, + ImportSpecifier = 216, + ExportAssignment = 217, + ExportDeclaration = 218, + NamedExports = 219, + ExportSpecifier = 220, + MissingDeclaration = 221, + ExternalModuleReference = 222, + CaseClause = 223, + DefaultClause = 224, + HeritageClause = 225, + CatchClause = 226, + PropertyAssignment = 227, + ShorthandPropertyAssignment = 228, + EnumMember = 229, + SourceFile = 230, + JSDocTypeExpression = 231, + JSDocAllType = 232, + JSDocUnknownType = 233, + JSDocArrayType = 234, + JSDocUnionType = 235, + JSDocTupleType = 236, + JSDocNullableType = 237, + JSDocNonNullableType = 238, + JSDocRecordType = 239, + JSDocRecordMember = 240, + JSDocTypeReference = 241, + JSDocOptionalType = 242, + JSDocFunctionType = 243, + JSDocVariadicType = 244, + JSDocConstructorType = 245, + JSDocThisType = 246, + JSDocComment = 247, + JSDocTag = 248, + JSDocParameterTag = 249, + JSDocReturnTag = 250, + JSDocTypeTag = 251, + JSDocTemplateTag = 252, + SyntaxList = 253, + Count = 254, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, LastReservedWord = 101, FirstKeyword = 66, - LastKeyword = 126, + LastKeyword = 127, FirstFutureReservedWord = 102, LastFutureReservedWord = 110, - FirstTypeNode = 142, - LastTypeNode = 150, + FirstTypeNode = 144, + LastTypeNode = 152, FirstPunctuation = 14, LastPunctuation = 64, FirstToken = 0, - LastToken = 126, + LastToken = 127, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -297,7 +306,7 @@ declare module ts { LastTemplateToken = 13, FirstBinaryOperator = 24, LastBinaryOperator = 64, - FirstNode = 127, + FirstNode = 128, } const enum NodeFlags { Export = 1, @@ -458,6 +467,10 @@ declare module ts { typeName: EntityName; typeArguments?: NodeArray; } + interface TypePredicateNode extends TypeNode { + parameterName: Identifier; + type: TypeNode; + } interface TypeQueryNode extends TypeNode { exprName: EntityName; } @@ -587,12 +600,12 @@ declare module ts { tag: LeftHandSideExpression; template: LiteralExpression | TemplateExpression; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } - interface Statement extends Node, ModuleElement { + interface Statement extends Node { _statementBrand: any; } interface Block extends Statement { @@ -672,9 +685,6 @@ declare module ts { variableDeclaration: VariableDeclaration; block: Block; } - interface ModuleElement extends Node { - _moduleElementBrand: any; - } interface ClassLikeDeclaration extends Declaration { name?: Identifier; typeParameters?: NodeArray; @@ -700,6 +710,7 @@ declare module ts { } interface TypeAliasDeclaration extends Declaration, Statement { name: Identifier; + typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { @@ -710,21 +721,21 @@ declare module ts { name: Identifier; members: NodeArray; } - interface ModuleDeclaration extends Declaration, ModuleElement { + interface ModuleDeclaration extends Declaration, Statement { name: Identifier | LiteralExpression; body: ModuleBlock | ModuleDeclaration; } - interface ModuleBlock extends Node, ModuleElement { - statements: NodeArray; + interface ModuleBlock extends Node, Statement { + statements: NodeArray; } - interface ImportEqualsDeclaration extends Declaration, ModuleElement { + interface ImportEqualsDeclaration extends Declaration, Statement { name: Identifier; moduleReference: EntityName | ExternalModuleReference; } interface ExternalModuleReference extends Node { expression?: Expression; } - interface ImportDeclaration extends ModuleElement { + interface ImportDeclaration extends Statement { importClause?: ImportClause; moduleSpecifier: Expression; } @@ -735,7 +746,7 @@ declare module ts { interface NamespaceImport extends Declaration { name: Identifier; } - interface ExportDeclaration extends Declaration, ModuleElement { + interface ExportDeclaration extends Declaration, Statement { exportClause?: NamedExports; moduleSpecifier?: Expression; } @@ -750,7 +761,7 @@ declare module ts { } type ImportSpecifier = ImportOrExportSpecifier; type ExportSpecifier = ImportOrExportSpecifier; - interface ExportAssignment extends Declaration, ModuleElement { + interface ExportAssignment extends Declaration, Statement { isExportEquals?: boolean; expression: Expression; } @@ -838,7 +849,7 @@ declare module ts { isBracketed: boolean; } interface SourceFile extends Declaration { - statements: NodeArray; + statements: NodeArray; endOfFileToken: Node; fileName: string; text: string; @@ -846,8 +857,16 @@ declare module ts { path: string; name: string; }[]; - amdModuleName: string; + moduleName: string; referencedFiles: FileReference[]; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } @@ -878,8 +897,9 @@ declare module ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; /** @@ -998,6 +1018,11 @@ declare module ts { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } + interface TypePredicate { + parameterName: string; + parameterIndex: number; + type: Type; + } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -1060,6 +1085,7 @@ declare module ts { ExportHasLocal = 944, HasExports = 1952, HasMembers = 6240, + BlockScoped = 418, PropertyOrAccessor = 98308, Export = 7340032, } @@ -1111,9 +1137,8 @@ declare module ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - } - interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; + resolvedBaseConstructorType?: Type; + resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1146,6 +1171,7 @@ declare module ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; + typePredicate?: TypePredicate; } const enum IndexKind { String = 0, @@ -1267,7 +1293,7 @@ declare module ts { newLength: number; } } -declare module ts { +declare namespace ts { interface System { args: string[]; newLine: string; @@ -1291,7 +1317,7 @@ declare module ts { } var sys: System; } -declare module ts { +declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } @@ -1323,12 +1349,13 @@ declare module ts { function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; } -declare module ts { +declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; function textSpanEnd(span: TextSpan): number; function textSpanIsEmpty(span: TextSpan): boolean; @@ -1338,6 +1365,7 @@ declare module ts { function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; function createTextSpan(start: number, length: number): TextSpan; @@ -1357,14 +1385,14 @@ declare module ts { function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration; } -declare module ts { +declare namespace ts { function getNodeConstructor(kind: SyntaxKind): new () => Node; function createNode(kind: SyntaxKind): Node; function forEachChild(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; } -declare module ts { +declare namespace ts { /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; @@ -1373,7 +1401,7 @@ declare module ts { function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; } -declare module ts { +declare namespace ts { function parseCommandLine(commandLine: string[]): ParsedCommandLine; /** * Read tsconfig.json file @@ -1400,7 +1428,7 @@ declare module ts { */ function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; } -declare module ts { +declare namespace ts { /** The version of the language service API */ let servicesVersion: string; interface Node { @@ -1490,6 +1518,7 @@ declare module ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; } interface LanguageService { cleanupSemanticCache(): void; @@ -1948,11 +1977,11 @@ declare module ts { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } - function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createDocumentRegistry(): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 3dd6dd919be..6373e3f9c58 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -144,176 +144,178 @@ var ts; SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 118] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 119] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 120] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 121] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 122] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 123] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 124] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 125] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 126] = "OfKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 117] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 118] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 119] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 120] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 121] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 122] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 123] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 124] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 125] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 126] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 127] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 127] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 128] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 128] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 129] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 129] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 130] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 131] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 130] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 131] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 132] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 132] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 133] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 134] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 135] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 136] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 137] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 138] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 139] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 140] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 141] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 133] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 134] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 135] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 136] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 137] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 138] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 139] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 140] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 141] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 142] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypeReference"] = 142] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 143] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 144] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 145] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 146] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 147] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 148] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 149] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 150] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 143] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 144] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 145] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 146] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 147] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 148] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 149] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 150] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 151] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 152] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 151] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 152] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 153] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 153] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 154] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 155] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 154] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 155] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 156] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 157] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 158] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 159] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 160] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 161] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 162] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 163] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 164] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 165] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 166] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 167] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 168] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 169] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 170] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 171] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 172] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 173] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 174] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 175] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 176] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 177] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 156] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 157] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 158] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 159] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 160] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 161] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 162] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 163] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 164] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 165] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 166] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 167] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 168] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 169] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 170] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 171] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 172] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 174] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 175] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 176] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 177] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 178] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 179] = "ExpressionWithTypeArguments"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 178] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 179] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 180] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 181] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 180] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 181] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 182] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 183] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 184] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 185] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 186] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 187] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 188] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 189] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 190] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 191] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 192] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 193] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 194] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 195] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 196] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 197] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 198] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 199] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 200] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 201] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 202] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 203] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 204] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 205] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 206] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 207] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 208] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 209] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 210] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 211] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 212] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 213] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 214] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 215] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 216] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 217] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 218] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 219] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 182] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 183] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 184] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 185] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 186] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 187] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 188] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 189] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 190] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 191] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 192] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 193] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 194] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 195] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 196] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 197] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 198] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 199] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 200] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 201] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 202] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 203] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 204] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 205] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 206] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 207] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 208] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 209] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 210] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 211] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 212] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 213] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 214] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 215] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 216] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 217] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 218] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 219] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 220] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 221] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 220] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 222] = "ExternalModuleReference"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 221] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 222] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 223] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 224] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 223] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 224] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 225] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 226] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 225] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 226] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 227] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 228] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 227] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 229] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 228] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 230] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 229] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 231] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 230] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 232] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 231] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 232] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 233] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 234] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 235] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 236] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 237] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 238] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 239] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 240] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 241] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 242] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 243] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 244] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 245] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 246] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 247] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 248] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 249] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 250] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 233] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 234] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 235] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 236] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 237] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 238] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 239] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 240] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 241] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 242] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 243] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 244] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 245] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 246] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 247] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 248] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 249] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 250] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 251] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 252] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 251] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 253] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 252] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 254] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 126] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 127] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 142] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 150] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 144] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 152] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 126] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 127] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -322,7 +324,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 127] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 128] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -349,9 +351,6 @@ var ts; /* @internal */ (function (ParserContextFlags) { ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // Set if this node was parsed in strict mode. Used for grammar error checks, as well as - // checking if the node can be reused in incremental settings. - ParserContextFlags[ParserContextFlags["StrictMode"] = 1] = "StrictMode"; // If this node was parsed in a context where 'in-expressions' are not allowed. ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; // If this node was parsed in the 'yield' context created when parsing a generator. @@ -368,7 +367,7 @@ var ts; // its type can be specified usign a JSDoc comment. ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 64] = "JavaScriptFile"; // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 62] = "ParserGeneratedFlags"; // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. @@ -494,8 +493,13 @@ var ts; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + /* @internal */ + // The set of things we consider semantically classifiable. Used to speed up the LS during + // classification. + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(ts.SymbolFlags || (ts.SymbolFlags = {})); var SymbolFlags = ts.SymbolFlags; /* @internal */ @@ -735,6 +739,36 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -1232,7 +1266,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { // If the path is not rooted it is relative to current directory path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); @@ -1896,14 +1930,32 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2097,6 +2149,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, 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}'." }, @@ -2274,9 +2331,7 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } }; })(ts || (ts = {})); /// @@ -2306,7 +2361,7 @@ var ts; "false": 80 /* FalseKeyword */, "finally": 81 /* FinallyKeyword */, "for": 82 /* ForKeyword */, - "from": 125 /* FromKeyword */, + "from": 126 /* FromKeyword */, "function": 83 /* FunctionKeyword */, "get": 116 /* GetKeyword */, "if": 84 /* IfKeyword */, @@ -2315,36 +2370,37 @@ var ts; "in": 86 /* InKeyword */, "instanceof": 87 /* InstanceOfKeyword */, "interface": 103 /* InterfaceKeyword */, + "is": 117 /* IsKeyword */, "let": 104 /* LetKeyword */, - "module": 117 /* ModuleKeyword */, - "namespace": 118 /* NamespaceKeyword */, + "module": 118 /* ModuleKeyword */, + "namespace": 119 /* NamespaceKeyword */, "new": 88 /* NewKeyword */, "null": 89 /* NullKeyword */, - "number": 120 /* NumberKeyword */, + "number": 121 /* NumberKeyword */, "package": 105 /* PackageKeyword */, "private": 106 /* PrivateKeyword */, "protected": 107 /* ProtectedKeyword */, "public": 108 /* PublicKeyword */, - "require": 119 /* RequireKeyword */, + "require": 120 /* RequireKeyword */, "return": 90 /* ReturnKeyword */, - "set": 121 /* SetKeyword */, + "set": 122 /* SetKeyword */, "static": 109 /* StaticKeyword */, - "string": 122 /* StringKeyword */, + "string": 123 /* StringKeyword */, "super": 91 /* SuperKeyword */, "switch": 92 /* SwitchKeyword */, - "symbol": 123 /* SymbolKeyword */, + "symbol": 124 /* SymbolKeyword */, "this": 93 /* ThisKeyword */, "throw": 94 /* ThrowKeyword */, "true": 95 /* TrueKeyword */, "try": 96 /* TryKeyword */, - "type": 124 /* TypeKeyword */, + "type": 125 /* TypeKeyword */, "typeof": 97 /* TypeOfKeyword */, "var": 98 /* VarKeyword */, "void": 99 /* VoidKeyword */, "while": 100 /* WhileKeyword */, "with": 101 /* WithKeyword */, "yield": 110 /* YieldKeyword */, - "of": 126 /* OfKeyword */, + "of": 127 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2604,8 +2660,31 @@ var ts; return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + // Keep in sync with skipTrivia + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + case 47 /* slash */: + // starts of normal trivia + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + // Starts of conflict marker trivia + return true; + default: + return ch > 127 /* maxAsciiCharacter */; + } + } + ts.couldStartTrivia = couldStartTrivia; /* @internal */ function skipTrivia(text, pos, stopAfterLineBreak) { + // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); switch (ch) { @@ -3109,7 +3188,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -3666,16 +3745,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 207 /* ModuleBlock */) { + else if (node.kind === 209 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3694,7 +3773,7 @@ var ts; }); return state; } - else if (node.kind === 206 /* ModuleDeclaration */) { + else if (node.kind === 208 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3734,11 +3813,17 @@ var ts; var container; var blockScopeContainer; var lastContainer; + // If this file is an external module, then it is automatically in strict-mode according to + // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -3766,10 +3851,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3777,22 +3862,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return "__constructor"; - case 143 /* FunctionType */: - case 139 /* CallSignature */: + case 145 /* FunctionType */: + case 140 /* CallSignature */: return "__call"; - case 144 /* ConstructorType */: - case 140 /* ConstructSignature */: + case 146 /* ConstructorType */: + case 141 /* ConstructSignature */: return "__new"; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return "__index"; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return "__export"; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: return node.flags & 256 /* Default */ ? "default" : undefined; } } @@ -3826,6 +3911,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0 /* None */, name)); + if (name && (includes & 788448 /* Classifiable */)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -3852,7 +3940,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 218 /* ExportSpecifier */ || (node.kind === 209 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 220 /* ExportSpecifier */ || (node.kind === 211 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3933,36 +4021,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 206 /* ModuleDeclaration */: - case 228 /* SourceFile */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 208 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 206 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 224 /* CatchClause */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 208 /* CaseBlock */: + case 226 /* CatchClause */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 210 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 180 /* Block */: + case 182 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -3995,45 +4084,47 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - // Modules, source files, and classes need specialized handling for how their + // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific - // symbol table depending on if it is static or not). As such, we defer to - // specialized handlers to take care of declaring these child members. - case 206 /* ModuleDeclaration */: + // symbol table depending on if it is static or not). We defer to specialized + // handlers to take care of declaring these child members. + case 208 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: - case 203 /* InterfaceDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: + case 205 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of - // their container. They are only accessible through an instance of their - // container, and are never in scope otherwise (even inside the body of the - // object / type / interface declaring them). + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). An exception is type parameters, + // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 206 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another - // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // they're only accessed 'lexically' (i.e. from code that exists underneath + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // they're only accessed 'lexically' (i.e. from code that exists underneath // their container in the tree. To accomplish this, we simply add their declared - // symbol to the 'locals' of the container. These symbols can then be found as + // symbol to the 'locals' of the container. These symbols can then be found as // the type checker walks up the containers, checking them for matching names. return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -4058,11 +4149,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 /* SourceFile */ ? node : node.body; - if (body.kind === 228 /* SourceFile */ || body.kind === 207 /* ModuleBlock */) { + var body = node.kind === 230 /* SourceFile */ ? node : node.body; + if (body.kind === 230 /* SourceFile */ || body.kind === 209 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 /* ExportDeclaration */ || stat.kind === 215 /* ExportAssignment */) { + if (stat.kind === 218 /* ExportDeclaration */ || stat.kind === 217 /* ExportAssignment */) { return true; } } @@ -4117,16 +4208,54 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65 /* Identifier */) { + continue; + } + var identifier = prop.name; + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + var currentKind = prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */ || prop.kind === 136 /* MethodDeclaration */ + ? 1 /* Property */ + : 2 /* Accessor */; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4143,11 +4272,126 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); } + // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized + // check for reserved words used as identifiers in strict mode code. + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 110 /* LastFutureReservedWord */ && + !ts.isIdentifierName(node)) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + // Grammar checking + if (inStrictMode && node.expression.kind === 65 /* Identifier */) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65 /* Identifier */) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384 /* OctalLiteral */) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + // Grammar checking + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + // Grammar checking + if (inStrictMode) { + if (node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -4164,76 +4408,132 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230 /* SourceFile */: + case 209 /* ModuleBlock */: + updateStrictModeStatementList(node.statements); + return; + case 182 /* Block */: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the + // string to contain unicode escapes (as per ES5). + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129 /* TypeParameter */: + case 65 /* Identifier */: + return checkStrictModeIdentifier(node); + case 172 /* BinaryExpression */: + return checkStrictModeBinaryExpression(node); + case 226 /* CatchClause */: + return checkStrictModeCatchClause(node); + case 167 /* DeleteExpression */: + return checkStrictModeDeleteExpression(node); + case 7 /* NumericLiteral */: + return checkStrictModeNumericLiteral(node); + case 171 /* PostfixUnaryExpression */: + return checkStrictModePostfixUnaryExpression(node); + case 170 /* PrefixUnaryExpression */: + return checkStrictModePrefixUnaryExpression(node); + case 195 /* WithStatement */: + return checkStrictModeWithStatement(node); + case 130 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 130 /* Parameter */: + case 131 /* Parameter */: return bindParameter(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: + checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 136 /* Constructor */: + case 137 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 155 /* ObjectLiteralExpression */: - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: + return bindObjectLiteralExpression(node); + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + checkStrictModeFunctionName(node); return bindAnonymousDeclaration(node, 16 /* Function */, "__function"); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return bindImportClause(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return bindExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return bindExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -4244,7 +4544,11 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65 /* Identifier */) { + if (!container.symbol || !container.symbol.exports) { + // Export assignment in some sort of block construct + bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); + } + else if (node.expression.kind === 65 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4254,7 +4558,11 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + // Export * in some sort of block construct + bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + } + else if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); } @@ -4265,7 +4573,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); } else { @@ -4297,6 +4605,9 @@ var ts; : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -4319,6 +4630,11 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); } @@ -4328,8 +4644,8 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 136 /* Constructor */ && - (node.parent.parent.kind === 202 /* ClassDeclaration */ || node.parent.parent.kind === 175 /* ClassExpression */)) { + node.parent.kind === 137 /* Constructor */ && + ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -4359,7 +4675,7 @@ var ts; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -4416,7 +4732,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228 /* SourceFile */) { + while (node && node.kind !== 230 /* SourceFile */) { node = node.parent; } return node; @@ -4526,15 +4842,15 @@ var ts; return current; } switch (current.kind) { - case 228 /* SourceFile */: - case 208 /* CaseBlock */: - case 224 /* CatchClause */: - case 206 /* ModuleDeclaration */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 230 /* SourceFile */: + case 210 /* CaseBlock */: + case 226 /* CatchClause */: + case 208 /* ModuleDeclaration */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return current; - case 180 /* Block */: + case 182 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4547,9 +4863,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 /* VariableDeclaration */ && + declaration.kind === 201 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 224 /* CatchClause */; + declaration.parent.kind === 226 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4588,7 +4904,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4597,16 +4913,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: errorNode = node.name; break; } @@ -4630,11 +4946,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 /* EnumDeclaration */ && isConst(node); + return node.kind === 207 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 155 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4649,14 +4965,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 200 /* VariableDeclarationList */) { + if (node && node.kind === 202 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181 /* VariableStatement */) { + if (node && node.kind === 183 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4671,12 +4987,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 185 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 130 /* Parameter */ || node.kind === 129 /* TypeParameter */) { + if (node.kind === 131 /* Parameter */ || node.kind === 130 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -4700,40 +5016,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 /* FirstTypeNode */ <= node.kind && node.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= node.kind && node.kind <= 152 /* LastTypeNode */) { return true; } switch (node.kind) { case 112 /* AnyKeyword */: - case 120 /* NumberKeyword */: - case 122 /* StringKeyword */: + case 121 /* NumberKeyword */: + case 123 /* StringKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return true; case 99 /* VoidKeyword */: - return node.parent.kind !== 167 /* VoidExpression */; + return node.parent.kind !== 169 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 130 /* Parameter */; - case 177 /* ExpressionWithTypeArguments */: - return true; + return node.parent.kind === 131 /* Parameter */; + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 65 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 127 /* QualifiedName */: - case 156 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145 /* TypeQuery */) { + if (parent_1.kind === 147 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4742,38 +5058,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (142 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 152 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 177 /* ExpressionWithTypeArguments */: - return true; - case 129 /* TypeParameter */: + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 130 /* TypeParameter */: return node === parent_1.constraint; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: return node === parent_1.type; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node === parent_1.type; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return node === parent_1.type; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_1.type; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4787,23 +5103,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitor(node); - case 208 /* CaseBlock */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 210 /* CaseBlock */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4813,17 +5129,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -4831,7 +5148,7 @@ var ts; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128 /* ComputedPropertyName */) { + if (name_4 && name_4.kind === 129 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_4.expression); @@ -4850,14 +5167,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153 /* BindingElement */: - case 227 /* EnumMember */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: return true; } } @@ -4865,38 +5182,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - if (node) { - switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - return true; - } - } - return false; + return node && (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - if (node) { - return node.kind === 202 /* ClassDeclaration */ || node.kind === 175 /* ClassExpression */; - } + return node && (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return true; } } @@ -4904,11 +5212,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 182 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 /* MethodDeclaration */ && node.parent.kind === 155 /* ObjectLiteralExpression */; + return node && node.kind === 136 /* MethodDeclaration */ && node.parent.kind === 157 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4920,6 +5228,15 @@ var ts; } } ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { while (true) { node = node.parent; @@ -4927,12 +5244,12 @@ var ts; return undefined; } switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (isClassLike(node.parent.parent)) { return node; } // If this is a computed property, then the parent should not @@ -4942,9 +5259,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -4955,23 +5272,23 @@ var ts; node = node.parent; } break; - case 164 /* ArrowFunction */: + case 166 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 206 /* ModuleDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 205 /* EnumDeclaration */: - case 228 /* SourceFile */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 208 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 207 /* EnumDeclaration */: + case 230 /* SourceFile */: return node; } } @@ -4983,12 +5300,12 @@ var ts; if (!node) return node; switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (isClassLike(node.parent.parent)) { return node; } // If this is a computed property, then the parent should not @@ -4998,9 +5315,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5011,72 +5328,72 @@ var ts; node = node.parent; } break; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { return node.tag; } - // Will either be a CallExpression or NewExpression. + // Will either be a CallExpression, NewExpression, or Decorator. return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // classes are valid targets return true; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 202 /* ClassDeclaration */; - case 130 /* Parameter */: + return node.parent.kind === 204 /* ClassDeclaration */; + case 131 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 202 /* ClassDeclaration */; - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 204 /* ClassDeclaration */; + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 202 /* ClassDeclaration */; + return node.body && node.parent.kind === 204 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: if (node.decorators) { return true; } return false; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5087,10 +5404,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5108,38 +5425,38 @@ var ts; case 95 /* TrueKeyword */: case 80 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 163 /* FunctionExpression */: - case 175 /* ClassExpression */: - case 164 /* ArrowFunction */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 172 /* TemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 165 /* FunctionExpression */: + case 177 /* ClassExpression */: + case 166 /* ArrowFunction */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 174 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 176 /* OmittedExpression */: - case 173 /* YieldExpression */: + case 178 /* OmittedExpression */: + case 175 /* YieldExpression */: return true; - case 127 /* QualifiedName */: - while (node.parent.kind === 127 /* QualifiedName */) { + case 128 /* QualifiedName */: + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 145 /* TypeQuery */; + return node.parent.kind === 147 /* TypeQuery */; case 65 /* Identifier */: - if (node.parent.kind === 145 /* TypeQuery */) { + if (node.parent.kind === 147 /* TypeQuery */) { return true; } // fall through @@ -5147,43 +5464,45 @@ var ts; case 8 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 227 /* EnumMember */: - case 225 /* PropertyAssignment */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 155 /* BindingElement */: return parent_2.initializer === node; - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 196 /* ThrowStatement */: - case 194 /* SwitchStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 198 /* ThrowStatement */: + case 196 /* SwitchStatement */: return parent_2.expression === node; - case 187 /* ForStatement */: + case 189 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forInStatement.expression === node; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_2.expression; - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return node === parent_2.expression; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return node === parent_2.expression; - case 131 /* Decorator */: + case 132 /* Decorator */: return true; + case 179 /* ExpressionWithTypeArguments */: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -5200,7 +5519,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5209,20 +5528,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 222 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 220 /* ExternalModuleReference */) { + if (reference.kind === 222 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 218 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5230,15 +5549,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: return node.questionToken !== undefined; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return node.questionToken !== undefined; - case 226 /* ShorthandPropertyAssignment */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5246,9 +5565,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 /* JSDocFunctionType */ && + return node.kind === 243 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 243 /* JSDocConstructorType */; + node.parameters[0].type.kind === 245 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5262,15 +5581,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249 /* JSDocTypeTag */); + return getJSDocTag(node, 251 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248 /* JSDocReturnTag */); + return getJSDocTag(node, 250 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250 /* JSDocTemplateTag */); + return getJSDocTag(node, 252 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5281,7 +5600,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247 /* JSDocParameterTag */) { + if (t.kind === 249 /* JSDocParameterTag */) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -5300,12 +5619,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64 /* JavaScriptFile */) { - if (node.type && node.type.kind === 242 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 244 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 244 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5326,7 +5645,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 /* ArrayBindingPattern */ || node.kind === 151 /* ObjectBindingPattern */); + return !!node && (node.kind === 154 /* ArrayBindingPattern */ || node.kind === 153 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5341,33 +5660,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164 /* ArrowFunction */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 136 /* Constructor */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 218 /* ExportSpecifier */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 211 /* ImportClause */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 203 /* InterfaceDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 206 /* ModuleDeclaration */: - case 212 /* NamespaceImport */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 138 /* SetAccessor */: - case 226 /* ShorthandPropertyAssignment */: - case 204 /* TypeAliasDeclaration */: - case 129 /* TypeParameter */: - case 199 /* VariableDeclaration */: + case 166 /* ArrowFunction */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 137 /* Constructor */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 220 /* ExportSpecifier */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 213 /* ImportClause */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 205 /* InterfaceDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 208 /* ModuleDeclaration */: + case 214 /* NamespaceImport */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 139 /* SetAccessor */: + case 228 /* ShorthandPropertyAssignment */: + case 206 /* TypeAliasDeclaration */: + case 130 /* TypeParameter */: + case 201 /* VariableDeclaration */: return true; } return false; @@ -5375,25 +5695,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 198 /* DebuggerStatement */: - case 185 /* DoStatement */: - case 183 /* ExpressionStatement */: - case 182 /* EmptyStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 195 /* LabeledStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 200 /* DebuggerStatement */: + case 187 /* DoStatement */: + case 185 /* ExpressionStatement */: + case 184 /* EmptyStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 197 /* LabeledStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: case 94 /* ThrowKeyword */: - case 197 /* TryStatement */: - case 181 /* VariableStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 215 /* ExportAssignment */: + case 199 /* TryStatement */: + case 183 /* VariableStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 217 /* ExportAssignment */: return true; default: return false; @@ -5402,13 +5722,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: return true; default: return false; @@ -5421,7 +5741,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 /* ImportSpecifier */ || parent.kind === 218 /* ExportSpecifier */) { + if (parent.kind === 216 /* ImportSpecifier */ || parent.kind === 220 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5432,6 +5752,41 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + // Return true if the given identifier is classified as an IdentifierName + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + // Name in member declaration or property name in property access + return parent.name === node; + case 128 /* QualifiedName */: + // Name on right hand side of dot in a type query + if (parent.right === node) { + while (parent.kind === 128 /* QualifiedName */) { + parent = parent.parent; + } + return parent.kind === 147 /* TypeQuery */; + } + return false; + case 155 /* BindingElement */: + case 216 /* ImportSpecifier */: + // Property name in binding element or import specifier + return parent.propertyName === node; + case 220 /* ExportSpecifier */: + // Any name in an export specifier + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; // An alias symbol is created by one of the following declarations: // import = ... // import from ... @@ -5441,12 +5796,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 211 /* ImportClause */ && !!node.name || - node.kind === 212 /* NamespaceImport */ || - node.kind === 214 /* ImportSpecifier */ || - node.kind === 218 /* ExportSpecifier */ || - node.kind === 215 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 213 /* ImportClause */ && !!node.name || + node.kind === 214 /* NamespaceImport */ || + node.kind === 216 /* ImportSpecifier */ || + node.kind === 220 /* ExportSpecifier */ || + node.kind === 217 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5529,7 +5884,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 126 /* LastKeyword */; + return 66 /* FirstKeyword */ <= token && token <= 127 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5545,7 +5900,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 /* ComputedPropertyName */ && + declaration.name.kind === 129 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5555,14 +5910,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 158 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 128 /* ComputedPropertyName */) { + if (name.kind === 129 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5600,18 +5955,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130 /* Parameter */; + return root.kind === 131 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153 /* BindingElement */) { + while (node.kind === 155 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 /* ModuleDeclaration */ || n.kind === 228 /* SourceFile */; + return isFunctionLike(n) || n.kind === 208 /* ModuleDeclaration */ || n.kind === 230 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5847,7 +6202,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -5872,10 +6227,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 138 /* SetAccessor */) { + else if (accessor.kind === 139 /* SetAccessor */) { setAccessor = accessor; } else { @@ -5884,7 +6239,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) + if ((member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5895,10 +6250,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 /* GetAccessor */ && !getAccessor) { + if (member.kind === 138 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 138 /* SetAccessor */ && !setAccessor) { + if (member.kind === 139 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6046,22 +6401,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 159 /* NewExpression */: - case 158 /* CallExpression */: - case 160 /* TaggedTemplateExpression */: - case 154 /* ArrayLiteralExpression */: - case 162 /* ParenthesizedExpression */: - case 155 /* ObjectLiteralExpression */: - case 175 /* ClassExpression */: - case 163 /* FunctionExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 161 /* NewExpression */: + case 160 /* CallExpression */: + case 162 /* TaggedTemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 164 /* ParenthesizedExpression */: + case 157 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 165 /* FunctionExpression */: case 65 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: case 80 /* FalseKeyword */: case 89 /* NullKeyword */: case 93 /* ThisKeyword */: @@ -6077,6 +6432,12 @@ var ts; return token >= 53 /* FirstAssignment */ && token <= 64 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 /* ExpressionWithTypeArguments */ && + node.parent.token === 79 /* ExtendsKeyword */ && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). function isSupportedExpressionWithTypeArguments(node) { @@ -6087,7 +6448,7 @@ var ts; if (node.kind === 65 /* Identifier */) { return true; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6095,8 +6456,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -6237,6 +6598,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -6396,9 +6763,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129 /* TypeParameter */) { + if (d && d.kind === 130 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205 /* InterfaceDeclaration */) { return current; } } @@ -6410,7 +6777,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252 /* Count */); + var nodeConstructors = new Array(254 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -6455,20 +6822,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6477,24 +6844,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6505,263 +6872,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 147 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 148 /* TupleType */: + case 150 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 149 /* UnionType */: + case 151 /* UnionType */: return visitNodes(cbNodes, node.types); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200 /* VariableDeclarationList */: + case 202 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return visitNode(cbNode, node.label); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 221 /* CaseClause */: + case 223 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 222 /* DefaultClause */: + case 224 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131 /* Decorator */: + case 132 /* Decorator */: return visitNode(cbNode, node.expression); - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 213 /* NamedImports */: - case 217 /* NamedExports */: + case 215 /* NamedImports */: + case 219 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220 /* ExternalModuleReference */: + case 222 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 229 /* JSDocTypeExpression */: + case 231 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 233 /* JSDocUnionType */: + case 235 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 234 /* JSDocTupleType */: + case 236 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 232 /* JSDocArrayType */: + case 234 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 236 /* JSDocNonNullableType */: + case 238 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 235 /* JSDocNullableType */: + case 237 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 237 /* JSDocRecordType */: + case 239 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 239 /* JSDocTypeReference */: + case 241 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240 /* JSDocOptionalType */: + case 242 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 241 /* JSDocFunctionType */: + case 243 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 242 /* JSDocVariadicType */: + case 244 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 243 /* JSDocConstructorType */: + case 245 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 244 /* JSDocThisType */: + case 246 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 238 /* JSDocRecordMember */: + case 240 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245 /* JSDocComment */: + case 247 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -6891,13 +7262,6 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - (function (StatementFlags) { - StatementFlags[StatementFlags["None"] = 0] = "None"; - StatementFlags[StatementFlags["Statement"] = 1] = "Statement"; - StatementFlags[StatementFlags["ModuleElement"] = 2] = "ModuleElement"; - StatementFlags[StatementFlags["StatementOrModuleElement"] = 3] = "StatementOrModuleElement"; - })(Parser.StatementFlags || (Parser.StatementFlags = {})); - var StatementFlags = Parser.StatementFlags; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); @@ -6936,7 +7300,7 @@ var ts; // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); ts.Debug.assert(token === 1 /* EndOfFileToken */); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -6962,9 +7326,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 130 /* Parameter */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 131 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7005,7 +7369,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228 /* SourceFile */, 0); + var sourceFile = createNode(230 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7023,9 +7387,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1 /* StrictMode */); - } function setDisallowInContext(val) { setContextFlag(val, 2 /* DisallowIn */); } @@ -7102,9 +7463,6 @@ var ts; function inYieldContext() { return (contextFlags & 4 /* Yield */) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1 /* StrictMode */) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8 /* GeneratorParameter */) !== 0; } @@ -7356,7 +7714,7 @@ var ts; // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] // - var node = createNode(128 /* ComputedPropertyName */); + var node = createNode(129 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -7414,37 +7772,34 @@ var ts; } switch (parsingContext) { case 0 /* SourceElements */: - case 1 /* ModuleElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfModuleElement(); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: - // During error recovery we don't treat empty statements as statements return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isStartOfTypeMember(); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); - case 10 /* ObjectBindingElements */: + case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. if (token === 14 /* OpenBraceToken */) { @@ -7459,29 +7814,29 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); - case 11 /* ArrayBindingElements */: + case 10 /* ArrayBindingElements */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: return isIdentifier(); - case 12 /* ArgumentExpressions */: - case 14 /* ArrayLiteralMembers */: + case 11 /* ArgumentExpressions */: + case 13 /* ArrayLiteralMembers */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); - case 15 /* Parameters */: + case 14 /* Parameters */: return isStartOfParameter(); - case 17 /* TypeArguments */: - case 18 /* TupleElementTypes */: + case 16 /* TypeArguments */: + case 17 /* TupleElementTypes */: return token === 23 /* CommaToken */ || isStartOfType(); - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return isHeritageClause(); - case 20 /* ImportOrExportSpecifiers */: + case 19 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); - case 21 /* JSDocFunctionParameters */: - case 22 /* JSDocTypeArguments */: - case 24 /* JSDocTupleTypes */: + case 20 /* JSDocFunctionParameters */: + case 21 /* JSDocTypeArguments */: + case 23 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -7523,47 +7878,46 @@ var ts; return true; } switch (kind) { - case 1 /* ModuleElements */: - case 2 /* BlockStatements */: - case 3 /* SwitchClauses */: - case 5 /* TypeMembers */: - case 6 /* ClassMembers */: - case 7 /* EnumMembers */: - case 13 /* ObjectLiteralMembers */: - case 10 /* ObjectBindingElements */: - case 20 /* ImportOrExportSpecifiers */: + case 1 /* BlockStatements */: + case 2 /* SwitchClauses */: + case 4 /* TypeMembers */: + case 5 /* ClassMembers */: + case 6 /* EnumMembers */: + case 12 /* ObjectLiteralMembers */: + case 9 /* ObjectBindingElements */: + case 19 /* ImportOrExportSpecifiers */: return token === 15 /* CloseBraceToken */; - case 4 /* SwitchClauseStatements */: + case 3 /* SwitchClauseStatements */: return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; - case 14 /* ArrayLiteralMembers */: - case 18 /* TupleElementTypes */: - case 11 /* ArrayBindingElements */: + case 13 /* ArrayLiteralMembers */: + case 17 /* TupleElementTypes */: + case 10 /* ArrayBindingElements */: return token === 19 /* CloseBracketToken */; - case 15 /* Parameters */: + case 14 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; - case 21 /* JSDocFunctionParameters */: + case 20 /* JSDocFunctionParameters */: return token === 17 /* CloseParenToken */ || token === 51 /* ColonToken */ || token === 15 /* CloseBraceToken */; - case 22 /* JSDocTypeArguments */: + case 21 /* JSDocTypeArguments */: return token === 25 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; - case 24 /* JSDocTupleTypes */: + case 23 /* JSDocTupleTypes */: return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return token === 15 /* CloseBraceToken */; } } @@ -7590,7 +7944,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 24 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -7600,47 +7954,25 @@ var ts; return false; } // Parses a list of elements - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - // test elements only if we are not already in strict mode - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the - // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -7688,7 +8020,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 63 /* ParserGeneratedFlags */; + var nodeContextFlags = node.parserContextFlags & 62 /* ParserGeneratedFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -7707,37 +8039,36 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1 /* ModuleElements */: - return isReusableModuleElement(node); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: return isReusableClassMember(node); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return isReusableSwitchClause(node); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: return isReusableStatement(node); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: return isReusableEnumMember(node); - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isReusableTypeMember(node); - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isReusableVariableDeclaration(node); - case 15 /* Parameters */: + case 14 /* Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 18 /* TupleElementTypes */: + case 17 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -7745,51 +8076,41 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // This is not safe to reuse for the same reason as the 'AssignmentExpression' // cases. i.e. a property assignment may end with an expression, and thus might // have lookahead far beyond it's old node. - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: // This is probably not safe to reuse. There can be speculative parsing with // type names in a heritage clause. There can be generic names in the type // name list, and there can be left hand side expressions (which can have type // arguments.) - case 8 /* HeritageClauseElement */: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - return true; - } - return isReusableStatement(node); + case 7 /* HeritageClauseElement */: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: - case 179 /* SemicolonClassElement */: + case 137 /* Constructor */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 181 /* SemicolonClassElement */: return true; + case 136 /* MethodDeclaration */: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 114 /* ConstructorKeyword */; + return !nameIsConstructor; } } return false; @@ -7797,8 +8118,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return true; } } @@ -7807,49 +8128,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 181 /* VariableStatement */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 183 /* ExpressionStatement */: - case 196 /* ThrowStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 182 /* EmptyStatement */: - case 197 /* TryStatement */: - case 195 /* LabeledStatement */: - case 185 /* DoStatement */: - case 198 /* DebuggerStatement */: + case 203 /* FunctionDeclaration */: + case 183 /* VariableStatement */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 185 /* ExpressionStatement */: + case 198 /* ThrowStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 184 /* EmptyStatement */: + case 199 /* TryStatement */: + case 197 /* LabeledStatement */: + case 187 /* DoStatement */: + case 200 /* DebuggerStatement */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 206 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227 /* EnumMember */; + return node.kind === 229 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140 /* ConstructSignature */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 132 /* PropertySignature */: - case 139 /* CallSignature */: + case 141 /* ConstructSignature */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 133 /* PropertySignature */: + case 140 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199 /* VariableDeclaration */) { + if (node.kind !== 201 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -7870,7 +8200,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130 /* Parameter */) { + if (node.kind !== 131 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -7889,30 +8219,29 @@ var ts; function parsingContextErrors(context) { switch (context) { case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 13 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 14 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 15 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 16 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 18 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 19 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 20 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 21 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 22 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 24 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 23 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; + case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 13 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 14 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 15 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 17 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 18 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 19 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 20 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 21 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 23 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 22 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -7986,7 +8315,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(127 /* QualifiedName */, entity.pos); + var node = createNode(128 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7994,38 +8323,38 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - // Technically a keyword is valid here as all keywords are identifier names. - // However, often we'll encounter this in error situations when the keyword + // Technically a keyword is valid here as all identifiers and keywords are identifier names. + // However, often we'll encounter this in error situations when the identifier or keyword // is actually starting another valid construct. // // So, we check for the following specific case: // // name. - // keyword identifierNameOrKeyword + // identifierOrKeyword identifierNameOrKeyword // // Note: the newlines are important here. For example, if that above code // were rewritten into: // - // name.keyword + // name.identifierOrKeyword // identifierNameOrKeyword // // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.keyword; identifierNameOrKeyword". + // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a - // line terminator after the keyword. - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + // line terminator after the identifier or keyword. + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually - // be an identifier and the error woudl be quite confusing. + // be an identifier and the error would be quite confusing. return createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172 /* TemplateExpression */); + var template = createNode(174 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8038,7 +8367,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178 /* TemplateSpan */); + var span = createNode(180 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -8078,22 +8407,30 @@ var ts; return node; } // TYPES - function parseTypeReference() { - var node = createNode(142 /* TypeReference */); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 /* Identifier */ && token === 117 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143 /* TypePredicate */, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144 /* TypeReference */, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145 /* TypeQuery */); + var node = createNode(147 /* TypeQuery */); parseExpected(97 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129 /* TypeParameter */); + var node = createNode(130 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(79 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8118,7 +8455,7 @@ var ts; } function parseTypeParameters() { if (token === 24 /* LessThanToken */) { - return parseBracketedList(16 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + return parseBracketedList(15 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } } function parseParameterType() { @@ -8139,7 +8476,7 @@ var ts; } } function parseParameter() { - var node = createNode(130 /* Parameter */); + var node = createNode(131 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); @@ -8210,7 +8547,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15 /* Parameters */, parseParameter); + var result = parseDelimitedList(14 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { @@ -8236,7 +8573,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140 /* ConstructSignature */) { + if (kind === 141 /* ConstructSignature */) { parseExpected(88 /* NewKeyword */); } fillSignature(51 /* ColonToken */, false, false, node); @@ -8300,10 +8637,10 @@ var ts; return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141 /* IndexSignature */, fullStart); + var node = createNode(142 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(14 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8313,7 +8650,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(134 /* MethodSignature */, fullStart); + var method = createNode(135 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -8323,7 +8660,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132 /* PropertySignature */, fullStart); + var property = createNode(133 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8365,7 +8702,7 @@ var ts; switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(139 /* CallSignature */); + return parseSignatureMember(140 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -8373,7 +8710,7 @@ var ts; : parsePropertyOrMethodSignature(); case 88 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140 /* ConstructSignature */); + return parseSignatureMember(141 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -8410,14 +8747,14 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(146 /* TypeLiteral */); + var node = createNode(148 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14 /* OpenBraceToken */)) { - members = parseList(5 /* TypeMembers */, false, parseTypeMember); + members = parseList(4 /* TypeMembers */, parseTypeMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -8426,12 +8763,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148 /* TupleType */); - node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(150 /* TupleType */); + node.elementTypes = parseBracketedList(17 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150 /* ParenthesizedType */); + var node = createNode(152 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -8439,7 +8776,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144 /* ConstructorType */) { + if (kind === 146 /* ConstructorType */) { parseExpected(88 /* NewKeyword */); } fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); @@ -8452,13 +8789,13 @@ var ts; function parseNonArrayType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99 /* VoidKeyword */: return parseTokenNode(); case 97 /* TypeOfKeyword */: @@ -8470,16 +8807,16 @@ var ts; case 16 /* OpenParenToken */: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 97 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: @@ -8503,7 +8840,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(147 /* ArrayType */, type.pos); + var node = createNode(149 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -8518,7 +8855,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149 /* UnionType */, type.pos); + var node = createNode(151 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } @@ -8573,10 +8910,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143 /* FunctionType */); + return parseFunctionOrConstructorType(145 /* FunctionType */); } if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(144 /* ConstructorType */); + return parseFunctionOrConstructorType(146 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -8745,11 +9082,6 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - // If we're in strict mode, then 'yield' is a keyword, could only ever start - // a yield expression. - return true; - } // We're in a context where 'yield expr' is not allowed. However, if we can // definitely tell that the user was trying to parse a 'yield expr' and not // just a normal expr that start with a 'yield' identifier, then parse out @@ -8764,7 +9096,7 @@ var ts; // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -8773,7 +9105,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173 /* YieldExpression */); + var node = createNode(175 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -8793,8 +9125,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164 /* ArrowFunction */, identifier.pos); - var parameter = createNode(130 /* Parameter */, identifier.pos); + var node = createNode(166 /* ArrowFunction */, identifier.pos); + var parameter = createNode(131 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8912,7 +9244,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164 /* ArrowFunction */); + var node = createNode(166 /* ArrowFunction */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -8974,7 +9306,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(171 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(173 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8987,7 +9319,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 126 /* OfKeyword */; + return t === 86 /* InKeyword */ || t === 127 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9053,33 +9385,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170 /* BinaryExpression */, left.pos); + var node = createNode(172 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168 /* PrefixUnaryExpression */); + var node = createNode(170 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165 /* DeleteExpression */); + var node = createNode(167 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166 /* TypeOfExpression */); + var node = createNode(168 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167 /* VoidExpression */); + var node = createNode(169 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9109,7 +9441,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(171 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9213,14 +9545,14 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(156 /* PropertyAccessExpression */, expression.pos); + var node = createNode(158 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161 /* TypeAssertionExpression */); + var node = createNode(163 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); parseExpected(25 /* GreaterThanToken */); @@ -9231,7 +9563,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(156 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(158 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -9240,7 +9572,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(157 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(159 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -9256,7 +9588,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(160 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(162 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -9279,7 +9611,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -9287,7 +9619,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -9298,7 +9630,7 @@ var ts; } function parseArgumentList() { parseExpected(16 /* OpenParenToken */); - var result = parseDelimitedList(12 /* ArgumentExpressions */, parseArgumentExpression); + var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); parseExpected(17 /* CloseParenToken */); return result; } @@ -9306,7 +9638,7 @@ var ts; if (!parseOptional(24 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(17 /* TypeArguments */, parseType); + var typeArguments = parseDelimitedList(16 /* TypeArguments */, parseType); if (!parseExpected(25 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -9389,41 +9721,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162 /* ParenthesizedExpression */); + var node = createNode(164 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174 /* SpreadElementExpression */); + var node = createNode(176 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(176 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(178 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154 /* ArrayLiteralExpression */); + var node = createNode(156 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 512 /* MultiLine */; - node.elements = parseDelimitedList(14 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(137 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(138 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(121 /* SetKeyword */)) { - return parseAccessorDeclaration(138 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(122 /* SetKeyword */)) { + return parseAccessorDeclaration(139 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -9446,13 +9778,13 @@ var ts; } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(228 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(227 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51 /* ColonToken */); @@ -9461,12 +9793,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155 /* ObjectLiteralExpression */); + var node = createNode(157 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512 /* MultiLine */; } - node.properties = parseDelimitedList(13 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } @@ -9479,7 +9811,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163 /* FunctionExpression */); + var node = createNode(165 /* FunctionExpression */); parseExpected(83 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -9494,7 +9826,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159 /* NewExpression */); + var node = createNode(161 /* NewExpression */); parseExpected(88 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -9504,10 +9836,10 @@ var ts; return finishNode(node); } // STATEMENTS - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180 /* Block */); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -9524,7 +9856,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -9532,12 +9864,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182 /* EmptyStatement */); + var node = createNode(184 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(184 /* IfStatement */); + var node = createNode(186 /* IfStatement */); parseExpected(84 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9547,7 +9879,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185 /* DoStatement */); + var node = createNode(187 /* DoStatement */); parseExpected(75 /* DoKeyword */); node.statement = parseStatement(); parseExpected(100 /* WhileKeyword */); @@ -9562,7 +9894,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186 /* WhileStatement */); + var node = createNode(188 /* WhileStatement */); parseExpected(100 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9585,21 +9917,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(188 /* ForInStatement */, pos); + var forInStatement = createNode(190 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126 /* OfKeyword */)) { - var forOfStatement = createNode(189 /* ForOfStatement */, pos); + else if (parseOptional(127 /* OfKeyword */)) { + var forOfStatement = createNode(191 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187 /* ForStatement */, pos); + var forStatement = createNode(189 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -9617,7 +9949,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -9625,7 +9957,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192 /* ReturnStatement */); + var node = createNode(194 /* ReturnStatement */); parseExpected(90 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -9634,7 +9966,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193 /* WithStatement */); + var node = createNode(195 /* WithStatement */); parseExpected(101 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9643,32 +9975,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221 /* CaseClause */); + var node = createNode(223 /* CaseClause */); parseExpected(67 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222 /* DefaultClause */); + var node = createNode(224 /* DefaultClause */); parseExpected(73 /* DefaultKeyword */); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194 /* SwitchStatement */); + var node = createNode(196 /* SwitchStatement */); parseExpected(92 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(208 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(210 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); - caseBlock.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -9681,7 +10013,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(196 /* ThrowStatement */); + var node = createNode(198 /* ThrowStatement */); parseExpected(94 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -9689,30 +10021,30 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(197 /* TryStatement */); + var node = createNode(199 /* TryStatement */); parseExpected(96 /* TryKeyword */); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. if (!node.catchClause || token === 81 /* FinallyKeyword */) { parseExpected(81 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224 /* CatchClause */); + var result = createNode(226 /* CatchClause */); parseExpected(68 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198 /* DebuggerStatement */); + var node = createNode(200 /* DebuggerStatement */); parseExpected(72 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -9724,13 +10056,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(195 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(197 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(185 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -9743,7 +10075,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98 /* VarKeyword */: @@ -9752,28 +10088,52 @@ var ts; case 83 /* FunctionKeyword */: case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: - return 1 /* Statement */; + return true; + // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; + // however, an identifier cannot be followed by another identifier on the same line. This is what we + // count on to parse out the respective declarations. For instance, we exploit this to say that + // + // namespace n + // + // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees + // + // namespace + // n + // + // as the identifier 'namespace' on one line followed by the identifier 'n' on another. + // We need to look one token ahead to see if it permissible to try parsing a declaration. + // + // *Note*: 'interface' is actually a strict mode reserved word. So while + // + // "use strict" + // interface + // I {} + // + // could be legal, it would add complexity for very little gain. case 103 /* InterfaceKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: + return nextTokenIsIdentifierOnSameLine(); + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115 /* DeclareKeyword */: nextToken(); - return isIdentifierOrKeyword() ? 1 /* Statement */ : 0 /* None */; - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - nextToken(); - return isIdentifierOrKeyword() || token === 8 /* StringLiteral */ ? 2 /* ModuleElement */ : 0 /* None */; + // ASI takes effect for this modifier. + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85 /* ImportKeyword */: nextToken(); return token === 8 /* StringLiteral */ || token === 35 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword() ? - 2 /* ModuleElement */ : 0 /* None */; + token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); case 78 /* ExportKeyword */: nextToken(); if (token === 53 /* EqualsToken */ || token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */ || token === 73 /* DefaultKeyword */) { - return 2 /* ModuleElement */; + return true; } continue; - case 115 /* DeclareKeyword */: case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: @@ -9781,14 +10141,14 @@ var ts; nextToken(); continue; default: - return 0 /* None */; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52 /* AtToken */: case 22 /* SemicolonToken */: @@ -9814,61 +10174,44 @@ var ts; // however, we say they are here so that we may gracefully parse them and error later. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: - return 1 /* Statement */; + return true; case 70 /* ConstKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115 /* DeclareKeyword */: case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - case 124 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + case 125 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement - return getDeclarationFlags() || 1 /* Statement */; + return true; case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 109 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 /* None */ : 1 /* Statement */); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 /* Statement */ : 0 /* None */; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1 /* Statement */) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3 /* StatementOrModuleElement */) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */); + return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; } function isLetDeclaration() { - // It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line. - // otherwise it needs to be treated like identifier - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1 /* Statement */); - } - function parseModuleElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseSourceElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22 /* SemicolonToken */: return parseEmptyStatement(); case 14 /* OpenBraceToken */: - return parseBlock(false, false); + return parseBlock(false); case 98 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104 /* LetKeyword */: @@ -9889,9 +10232,9 @@ var ts; case 82 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(190 /* ContinueStatement */); + return parseBreakOrContinueStatement(192 /* ContinueStatement */); case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(191 /* BreakStatement */); + return parseBreakOrContinueStatement(193 /* BreakStatement */); case 90 /* ReturnKeyword */: return parseReturnStatement(); case 101 /* WithKeyword */: @@ -9901,7 +10244,7 @@ var ts; case 94 /* ThrowKeyword */: return parseThrowStatement(); case 96 /* TryKeyword */: - // Include the next two for error recovery. + // Include 'catch' and 'finally' for error recovery. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: return parseTryStatement(); @@ -9909,20 +10252,20 @@ var ts; return parseDebuggerStatement(); case 52 /* AtToken */: return parseDeclaration(); - case 70 /* ConstKeyword */: + case 103 /* InterfaceKeyword */: + case 125 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: case 115 /* DeclareKeyword */: + case 70 /* ConstKeyword */: case 77 /* EnumKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 108 /* PublicKeyword */: case 109 /* StaticKeyword */: - case 124 /* TypeKeyword */: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -9944,12 +10287,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -9959,10 +10302,10 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(219 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(221 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -9970,6 +10313,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); @@ -9980,16 +10327,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(176 /* OmittedExpression */); + return createNode(178 /* OmittedExpression */); } - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -10005,16 +10352,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151 /* ObjectBindingPattern */); + var node = createNode(153 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); - node.elements = parseDelimitedList(10 /* ObjectBindingElements */, parseObjectBindingElement); + node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152 /* ArrayBindingPattern */); + var node = createNode(154 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); - node.elements = parseDelimitedList(11 /* ArrayBindingElements */, parseArrayBindingElement); + node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } @@ -10031,7 +10378,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199 /* VariableDeclaration */); + var node = createNode(201 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -10040,7 +10387,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200 /* VariableDeclarationList */); + var node = createNode(202 /* VariableDeclarationList */); switch (token) { case 98 /* VarKeyword */: break; @@ -10063,13 +10410,13 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 126 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); + node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -10078,7 +10425,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181 /* VariableStatement */, fullStart); + var node = createNode(183 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -10086,7 +10433,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201 /* FunctionDeclaration */, fullStart); + var node = createNode(203 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83 /* FunctionKeyword */); @@ -10097,7 +10444,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136 /* Constructor */, pos); + var node = createNode(137 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114 /* ConstructorKeyword */); @@ -10106,7 +10453,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135 /* MethodDeclaration */, fullStart); + var method = createNode(136 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10117,7 +10464,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133 /* PropertyDeclaration */, fullStart); + var property = createNode(134 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -10209,7 +10556,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 121 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 122 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -10243,7 +10590,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131 /* Decorator */, decoratorStart); + var decorator = createNode(132 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -10276,7 +10623,7 @@ var ts; } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(179 /* SemicolonClassElement */); + var result = createNode(181 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -10302,7 +10649,7 @@ var ts; token === 18 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. var name_6 = createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); @@ -10314,15 +10661,12 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 175 /* ClassExpression */); + /*modifiers*/ undefined, 177 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -10342,9 +10686,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -10358,23 +10700,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19 /* HeritageClauses */, false, parseHeritageClause); + return parseList(18 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(223 /* HeritageClause */); + var node = createNode(225 /* HeritageClause */); node.token = token; nextToken(); - node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177 /* ExpressionWithTypeArguments */); + var node = createNode(179 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } @@ -10382,10 +10724,10 @@ var ts; return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; } function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassElement); + return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* InterfaceDeclaration */, fullStart); + var node = createNode(205 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103 /* InterfaceKeyword */); @@ -10396,11 +10738,12 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204 /* TypeAliasDeclaration */, fullStart); + var node = createNode(206 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124 /* TypeKeyword */); + parseExpected(125 /* TypeKeyword */); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53 /* EqualsToken */); node.type = parseType(); parseSemicolon(); @@ -10411,19 +10754,19 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(227 /* EnumMember */, scanner.getStartPos()); + var node = createNode(229 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* EnumDeclaration */, fullStart); + var node = createNode(207 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(14 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); + node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -10432,9 +10775,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(209 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { - node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -10443,7 +10786,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -10454,7 +10797,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -10463,11 +10806,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118 /* NamespaceKeyword */)) { + if (parseOptional(119 /* NamespaceKeyword */)) { flags |= 32768 /* Namespace */; } else { - parseExpected(117 /* ModuleKeyword */); + parseExpected(118 /* ModuleKeyword */); if (token === 8 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -10475,7 +10818,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 /* RequireKeyword */ && + return token === 120 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -10484,7 +10827,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 125 /* FromKeyword */; + token === 126 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85 /* ImportKeyword */); @@ -10492,11 +10835,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 125 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 126 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(209 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(211 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -10507,7 +10850,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(210 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(212 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -10517,7 +10860,7 @@ var ts; token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -10530,7 +10873,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211 /* ImportClause */, fullStart); + var importClause = createNode(213 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -10540,7 +10883,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(213 /* NamedImports */); + importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(215 /* NamedImports */); } return finishNode(importClause); } @@ -10550,8 +10893,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220 /* ExternalModuleReference */); - parseExpected(119 /* RequireKeyword */); + var node = createNode(222 /* ExternalModuleReference */); + parseExpected(120 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -10572,7 +10915,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(212 /* NamespaceImport */); + var namespaceImport = createNode(214 /* NamespaceImport */); parseExpected(35 /* AsteriskToken */); parseExpected(111 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -10587,14 +10930,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 213 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(19 /* ImportOrExportSpecifiers */, kind === 215 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218 /* ExportSpecifier */); + return parseImportOrExportSpecifier(220 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214 /* ImportSpecifier */); + return parseImportOrExportSpecifier(216 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -10619,23 +10962,23 @@ var ts; else { node.name = identifierName; } - if (kind === 214 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 216 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ExportDeclaration */, fullStart); + var node = createNode(218 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217 /* NamedExports */); - if (parseOptional(125 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(219 /* NamedExports */); + if (parseOptional(126 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -10643,7 +10986,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215 /* ExportAssignment */, fullStart); + var node = createNode(217 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53 /* EqualsToken */)) { @@ -10711,15 +11054,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */ - || node.kind === 210 /* ImportDeclaration */ - || node.kind === 215 /* ExportAssignment */ - || node.kind === 216 /* ExportDeclaration */ + || node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */ + || node.kind === 212 /* ImportDeclaration */ + || node.kind === 217 /* ExportAssignment */ + || node.kind === 218 /* ExportDeclaration */ ? node : undefined; }); @@ -10727,31 +11070,30 @@ var ts; var ParsingContext; (function (ParsingContext) { ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; - ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 8] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 10] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 11] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 12] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 13] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 14] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 15] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 16] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 17] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 18] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 19] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 20] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 21] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 22] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 23] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 24] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 25] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 13] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 14] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 15] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 16] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 17] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 18] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 19] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 20] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 21] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 22] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 23] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -10793,7 +11135,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(229 /* JSDocTypeExpression */); + var result = createNode(231 /* JSDocTypeExpression */); parseExpected(14 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(15 /* CloseBraceToken */); @@ -10804,12 +11146,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44 /* BarToken */) { - var unionType = createNode(233 /* JSDocUnionType */, type.pos); + var unionType = createNode(235 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53 /* EqualsToken */) { - var optionalType = createNode(240 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -10820,20 +11162,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(232 /* JSDocArrayType */, type.pos); + var arrayType = createNode(234 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 50 /* QuestionToken */) { - var nullableType = createNode(235 /* JSDocNullableType */, type.pos); + var nullableType = createNode(237 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46 /* ExclamationToken */) { - var nonNullableType = createNode(236 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(238 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -10867,40 +11209,40 @@ var ts; case 93 /* ThisKeyword */: return parseJSDocThisType(); case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244 /* JSDocThisType */); + var result = createNode(246 /* JSDocThisType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243 /* JSDocConstructorType */); + var result = createNode(245 /* JSDocConstructorType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242 /* JSDocVariadicType */); + var result = createNode(244 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241 /* JSDocFunctionType */); + var result = createNode(243 /* JSDocFunctionType */); nextToken(); parseExpected(16 /* OpenParenToken */); - result.parameters = parseDelimitedList(21 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(20 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17 /* CloseParenToken */); if (token === 51 /* ColonToken */) { @@ -10910,18 +11252,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130 /* Parameter */); + var parameter = createNode(131 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240 /* JSDocOptionalType */, type.pos); + var result = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239 /* JSDocTypeReference */); + var result = createNode(241 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(20 /* DotToken */)) { if (token === 24 /* LessThanToken */) { @@ -10937,7 +11279,7 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(22 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(21 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25 /* GreaterThanToken */); @@ -10951,21 +11293,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127 /* QualifiedName */, left.pos); + var result = createNode(128 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237 /* JSDocRecordType */); + var result = createNode(239 /* JSDocRecordType */); nextToken(); - result.members = parseDelimitedList(23 /* JSDocRecordMembers */, parseJSDocRecordMember); + result.members = parseDelimitedList(22 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238 /* JSDocRecordMember */); + var result = createNode(240 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 51 /* ColonToken */) { nextToken(); @@ -10974,15 +11316,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236 /* JSDocNonNullableType */); + var result = createNode(238 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234 /* JSDocTupleType */); + var result = createNode(236 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(24 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(23 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19 /* CloseBracketToken */); return finishNode(result); @@ -10994,7 +11336,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233 /* JSDocUnionType */); + var result = createNode(235 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17 /* CloseParenToken */); @@ -11012,7 +11354,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230 /* JSDocAllType */); + var result = createNode(232 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11035,11 +11377,11 @@ var ts; token === 25 /* GreaterThanToken */ || token === 53 /* EqualsToken */ || token === 44 /* BarToken */) { - var result = createNode(231 /* JSDocUnknownType */, pos); + var result = createNode(233 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(235 /* JSDocNullableType */, pos); + var result = createNode(237 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -11127,7 +11469,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245 /* JSDocComment */, start); + var result = createNode(247 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -11165,7 +11507,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246 /* JSDocTag */, atToken.pos); + var result = createNode(248 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -11217,7 +11559,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247 /* JSDocParameterTag */, atToken.pos); + var result = createNode(249 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -11227,27 +11569,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248 /* JSDocReturnTag */, atToken.pos); + var result = createNode(250 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249 /* JSDocTypeTag */, atToken.pos); + var result = createNode(251 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -11260,7 +11602,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129 /* TypeParameter */, name_7.pos); + var typeParameter = createNode(130 /* TypeParameter */, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -11271,7 +11613,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(252 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -11857,8 +12199,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -11874,10 +12216,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -11909,6 +12248,11 @@ var ts; flags: 2097152 /* ESSymbol */ } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -12051,10 +12395,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228 /* SourceFile */); + return ts.getAncestor(node, 230 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 228 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 230 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12111,40 +12455,54 @@ var ts; } } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 206 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { - if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 218 /* ExportSpecifier */)) { - break loop; + case 208 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 /* SourceFile */ || + (location.kind === 208 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExports[name], 220 /* ExportSpecifier */)) { + break; } - result = undefined; - } - else if (location.kind === 228 /* SourceFile */ || - (location.kind === 206 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { + break loop; + } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === 202 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -12154,8 +12512,9 @@ var ts; } } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 205 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -12166,6 +12525,13 @@ var ts; } break loop; } + if (location.kind === 177 /* ClassExpression */ && meaning & 32 /* Class */) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } break; // It is not legal to reference a class's own type parameters from a computed property name that // belongs to the class. For example: @@ -12175,9 +12541,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (grandparent.kind === 202 /* ClassDeclaration */ || grandparent.kind === 203 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 205 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -12185,19 +12551,19 @@ var ts; } } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -12210,16 +12576,7 @@ var ts; } } break; - case 175 /* ClassExpression */: - if (meaning & 32 /* Class */) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -12228,7 +12585,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 130 /* Parameter */) { + if (location.parent && location.parent.kind === 131 /* Parameter */) { location = location.parent; } // @@ -12284,16 +12641,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 199 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 201 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 187 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 183 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 189 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 188 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 190 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -12320,10 +12677,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 210 /* ImportDeclaration */) { + while (node && node.kind !== 212 /* ImportDeclaration */) { node = node.parent; } return node; @@ -12333,7 +12690,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 222 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12440,17 +12797,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return getTargetOfImportClause(node); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 214 /* ImportSpecifier */: + case 216 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 218 /* ExportSpecifier */: + case 220 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -12495,11 +12852,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215 /* ExportAssignment */) { + if (node.kind === 217 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 218 /* ExportSpecifier */) { + else if (node.kind === 220 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -12512,7 +12869,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 211 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -12525,13 +12882,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 127 /* QualifiedName */) { + if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 128 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 209 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 211 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -12551,9 +12908,9 @@ var ts; return undefined; } } - else if (name.kind === 127 /* QualifiedName */ || name.kind === 156 /* PropertyAccessExpression */) { - var left = name.kind === 127 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 127 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 128 /* QualifiedName */ || name.kind === 158 /* PropertyAccessExpression */) { + var left = name.kind === 128 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 128 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12714,7 +13071,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -12784,17 +13141,17 @@ var ts; } } switch (location_1.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12943,8 +13300,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 228 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 208 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 230 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12980,12 +13337,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 145 /* TypeQuery */) { + if (entityName.parent.kind === 147 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 127 /* QualifiedName */ || entityName.kind === 156 /* PropertyAccessExpression */ || - entityName.parent.kind === 209 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 128 /* QualifiedName */ || entityName.kind === 158 /* PropertyAccessExpression */ || + entityName.parent.kind === 211 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13019,6 +13376,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -13033,10 +13397,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150 /* ParenthesizedType */) { + while (node.kind === 152 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 206 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -13045,19 +13409,28 @@ var ts; // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. var _displayBuilder; function getSymbolDisplayBuilder() { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 177 /* ClassExpression */: + return "(Anonymous class)"; + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + return "(Anonymous function)"; + } + } + return symbol.name; + } /** * Writes only the name of the symbol out to the writer. Uses the original source text * for the name of the symbol if it is available to match how the user inputted the name. */ function appendSymbolNameOnly(symbol, writer) { - if (symbol.declarations && symbol.declarations.length > 0) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - writer.writeSymbol(ts.declarationNameToString(declaration.name), symbol); - return; - } - } - writer.writeSymbol(symbol.name, symbol); + writer.writeSymbol(getNameOfSymbol(symbol), symbol); } /** * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope @@ -13286,7 +13659,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 /* SourceFile */ || declaration.parent.kind === 207 /* ModuleBlock */; + return declaration.parent.kind === 230 /* SourceFile */ || declaration.parent.kind === 209 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -13364,7 +13737,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 122 /* StringKeyword */); + writeKeyword(writer, 123 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13378,7 +13751,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 120 /* NumberKeyword */); + writeKeyword(writer, 121 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13421,7 +13794,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -13525,12 +13898,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 228 /* SourceFile */) { + else if (node.kind === 230 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -13579,69 +13952,69 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153 /* BindingElement */: + case 155 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 206 /* ModuleDeclaration */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 201 /* FunctionDeclaration */: - case 205 /* EnumDeclaration */: - case 209 /* ImportEqualsDeclaration */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 203 /* FunctionDeclaration */: + case 207 /* EnumDeclaration */: + case 211 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 209 /* ImportEqualsDeclaration */ && parent_4.kind !== 228 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 /* ImportEqualsDeclaration */ && parent_4.kind !== 230 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 136 /* Constructor */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: - case 130 /* Parameter */: - case 207 /* ModuleBlock */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: - case 142 /* TypeReference */: - case 147 /* ArrayType */: - case 148 /* TupleType */: - case 149 /* UnionType */: - case 150 /* ParenthesizedType */: + case 137 /* Constructor */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: + case 131 /* Parameter */: + case 209 /* ModuleBlock */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: + case 144 /* TypeReference */: + case 149 /* ArrayType */: + case 150 /* TupleType */: + case 151 /* UnionType */: + case 152 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: return false; // Type parameters are always visible - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: // Source file is always visible - case 228 /* SourceFile */: + case 230 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -13657,10 +14030,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 217 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218 /* ExportSpecifier */) { + else if (node.parent.kind === 220 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -13718,7 +14091,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 199 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 201 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -13754,7 +14127,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_9 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -13801,10 +14174,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 188 /* ForInStatement */) { + if (declaration.parent.parent.kind === 190 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 191 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -13818,11 +14191,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 138 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137 /* GetAccessor */); + if (func.kind === 139 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13838,7 +14211,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 226 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 228 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -13873,7 +14246,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -13896,7 +14269,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 /* ObjectBindingPattern */ + return pattern.kind === 153 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -13918,7 +14291,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 225 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 227 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -13930,7 +14303,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13945,11 +14318,11 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224 /* CatchClause */) { + if (declaration.parent.kind === 226 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 215 /* ExportAssignment */) { + if (declaration.kind === 217 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -13980,7 +14353,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13996,8 +14369,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 138 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 139 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -14026,7 +14399,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -14126,9 +14499,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 /* ClassDeclaration */ || node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || node.kind === 135 /* MethodDeclaration */ || - node.kind === 164 /* ArrowFunction */) { + if (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */ || + node.kind === 203 /* FunctionDeclaration */ || node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */ || node.kind === 166 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14138,15 +14511,17 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 /* Class */ ? 202 /* ClassDeclaration */ : 203 /* InterfaceDeclaration */; - return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); + return appendOuterTypeParameters(undefined, declaration); } - // The local type parameters are the combined set of type parameters from all declarations of the class or interface. - function getLocalTypeParametersOfClassOrInterface(symbol) { + // The local type parameters are the combined set of type parameters from all declarations of the class, + // interface, or type alias. + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 204 /* ClassDeclaration */ || + node.kind === 177 /* ClassExpression */ || node.kind === 206 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14158,56 +14533,122 @@ var ts; // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus // its locally declared type parameters. function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // unknownType if an error occurred during resolution of the extends expression, + // nullType if the extends expression is the null value, or + // an object type with at least one construct signature. + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128 /* ObjectType */) { + // Resolving the members of a class requires us to resolve the base class of that class. + // We force resolution here such that we catch circularities now. + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32 /* Class */) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64 /* Interface */) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202 /* ClassDeclaration */); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024 /* Class */) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128 /* ObjectType */)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); @@ -14227,7 +14668,7 @@ var ts; var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -14249,9 +14690,18 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 206 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + // Initialize the instantiation cache for generic type aliases. The declared type corresponds to + // an instantiation of the type alias with the type parameters supplied as type arguments. + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -14273,7 +14723,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14388,34 +14838,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1 /* Construct */); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 /* Reference */ ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -14521,10 +14979,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128 /* ObjectType */) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -14745,7 +15203,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -14767,24 +15225,33 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143 /* TypePredicate */) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 137 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138 /* SetAccessor */); + if (declaration.kind === 138 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -14795,19 +15262,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -14884,7 +15351,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 /* Constructor */ || signature.declaration.kind === 140 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 137 /* Constructor */ || signature.declaration.kind === 141 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 131072 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -14898,7 +15365,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 120 /* NumberKeyword */ : 122 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 121 /* NumberKeyword */ : 123 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -14928,13 +15395,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -14987,13 +15454,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 144 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -15005,7 +15472,7 @@ var ts; // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -15019,62 +15486,82 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - // We don't currently support heritage clauses with complex expressions in them. - // For these cases, we just set the type to be the unknownType. - if (node.kind !== 177 /* ExpressionWithTypeArguments */ || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 /* TypeReference */ - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056 /* Type */); - if (symbol) { - if ((symbol.flags & 262144 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // Implementation: such type references are resolved to 'unknown' type that usually denotes error - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + // Get type from reference to class or interface + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; - } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */) && type.flags & 4096 /* Reference */) { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - // When no type arguments are expected we already have the right type because all outer type parameters - // have themselves as default type arguments. - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), expectedTypeArgCount); - return undefined; - } + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include + // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the + // declared type. Instantiations are cached using the type identities of the type arguments as the key. + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // Implementation: such type references are resolved to 'unknown' type that usually denotes error + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 144 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the + // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -15082,7 +15569,7 @@ var ts; // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -15092,9 +15579,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: return declaration; } } @@ -15129,6 +15616,15 @@ var ts; function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + /** + * Creates a TypeReference for a generic `TypedPropertyDescriptor`. + */ + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -15307,40 +15803,42 @@ var ts; switch (node.kind) { case 112 /* AnyKeyword */: return anyType; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: return stringType; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return numberType; case 113 /* BooleanKeyword */: return booleanType; - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return esSymbolType; case 99 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 142 /* TypeReference */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177 /* ExpressionWithTypeArguments */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145 /* TypeQuery */: + case 144 /* TypeReference */: + return getTypeFromTypeReference(node); + case 143 /* TypePredicate */: + return booleanType; + case 179 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReference(node); + case 147 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15430,11 +15928,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -15499,27 +16005,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return node.operatorToken.kind === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -15527,14 +16033,14 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } @@ -15542,9 +16048,6 @@ var ts; return type; } // TYPE CHECKING - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -15560,8 +16063,8 @@ var ts; function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source, target, errorNode, headMessage) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); @@ -15821,9 +16324,9 @@ var ts; maybeStack[depth][id] = 1 /* Succeeded */; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -15859,27 +16362,6 @@ var ts; } return result; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -16060,6 +16542,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0 /* False */; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -16150,6 +16659,27 @@ var ts; return 0 /* False */; } } + // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case + // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. + // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at + // some level beyond that. + function isDeeplyNestedGeneric(type, stack, depth) { + // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) + if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; } @@ -16356,22 +16886,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130 /* Parameter */: + case 131 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16444,20 +16974,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 /* Reference */ && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -16527,22 +17043,26 @@ var ts; else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; } } function inferFromProperties(source, target) { @@ -16567,7 +17087,17 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + // Return types from type predicates are treated as booleans. In order to infer types + // from type predicates we would need to infer using the type within the type predicate + // (i.e. 'Foo' from 'x is Foo'). + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -16640,10 +17170,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return true; case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: node = node.parent; continue; default: @@ -16691,7 +17221,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { var n = node.left; - while (n.kind === 162 /* ParenthesizedExpression */) { + while (n.kind === 164 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -16708,46 +17238,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 168 /* PrefixUnaryExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 169 /* PostfixUnaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 170 /* PrefixUnaryExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 171 /* PostfixUnaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -16800,19 +17330,19 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184 /* IfStatement */: + case 186 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { @@ -16823,14 +17353,14 @@ var ts; } } break; - case 228 /* SourceFile */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: + case 230 /* SourceFile */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -16847,7 +17377,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 166 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 168 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; @@ -16923,7 +17453,7 @@ var ts; var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - // Target type is type of the protoype property + // Target type is type of the prototype property var prototypePropertyType = getTypeOfSymbol(prototypeProperty); if (!isTypeAny(prototypePropertyType)) { targetType = prototypePropertyType; @@ -16943,14 +17473,36 @@ var ts; } } if (targetType) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (originalType.flags & 16384 /* Union */) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1 /* Any */) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } @@ -16958,9 +17510,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -16975,7 +17529,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -16992,7 +17546,7 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -17016,7 +17570,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 224 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 226 /* CatchClause */) { return; } // - check if binding is used in some function @@ -17025,12 +17579,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 200 /* VariableDeclarationList */) { + while (container.kind !== 202 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 181 /* VariableStatement */) { + if (container.kind === 183 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -17049,9 +17603,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 133 /* PropertyDeclaration */ || container.kind === 136 /* Constructor */) { + if (container.kind === 134 /* PropertyDeclaration */ || container.kind === 137 /* Constructor */) { + var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -17064,64 +17618,61 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 164 /* ArrowFunction */) { + if (container.kind === 166 /* ArrowFunction */) { container = ts.getThisContainer(container, false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 136 /* Constructor */: + case 137 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; - if (classNode) { - var symbol = getSymbolOfNode(classNode); + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130 /* Parameter */) { + if (n.kind === 131 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -17131,7 +17682,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 136 /* Constructor */; + canUseSuperExpression = container.kind === 137 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -17140,28 +17691,28 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 164 /* ArrowFunction */) { + while (container && container.kind === 166 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === 202 /* ClassDeclaration */) { + if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */ || - container.kind === 133 /* PropertyDeclaration */ || - container.kind === 132 /* PropertySignature */ || - container.kind === 136 /* Constructor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */ || + container.kind === 134 /* PropertyDeclaration */ || + container.kind === 133 /* PropertySignature */ || + container.kind === 137 /* Constructor */; } } } @@ -17169,13 +17720,13 @@ var ts; var returnType; if ((container.flags & 128 /* Static */) || isCallExpression) { getNodeLinks(node).flags |= 32 /* SuperStatic */; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16 /* SuperInstance */; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; @@ -17189,7 +17740,7 @@ var ts; return returnType; } } - if (container && container.kind === 128 /* ComputedPropertyName */) { + if (container && container.kind === 129 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -17234,7 +17785,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17269,8 +17820,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 136 /* Constructor */ || - functionDecl.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138 /* SetAccessor */))) { + functionDecl.kind === 137 /* Constructor */ || + functionDecl.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -17292,7 +17843,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160 /* TaggedTemplateExpression */) { + if (template.parent.kind === 162 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17423,34 +17974,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 155 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 164 /* ArrowFunction */: - case 192 /* ReturnStatement */: + case 166 /* ArrowFunction */: + case 194 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 178 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 172 /* TemplateExpression */); + case 180 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 174 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return getContextualType(parent); } return undefined; @@ -17467,7 +18018,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 /* FunctionExpression */ || node.kind === 164 /* ArrowFunction */; + return node.kind === 165 /* FunctionExpression */ || node.kind === 166 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -17481,7 +18032,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -17537,13 +18088,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 172 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 225 /* PropertyAssignment */) { + if (parent.kind === 227 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154 /* ArrayLiteralExpression */) { + if (parent.kind === 156 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -17568,7 +18119,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 176 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -17592,7 +18143,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 176 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -17603,7 +18154,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -17662,18 +18213,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 /* PropertyAssignment */ || - memberDecl.kind === 226 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 227 /* PropertyAssignment */ || + memberDecl.kind === 228 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225 /* PropertyAssignment */) { + if (memberDecl.kind === 227 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135 /* MethodDeclaration */) { + else if (memberDecl.kind === 136 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 228 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -17693,7 +18244,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 137 /* GetAccessor */ || memberDecl.kind === 138 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 138 /* GetAccessor */ || memberDecl.kind === 139 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -17732,7 +18283,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 134 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -17745,7 +18296,7 @@ var ts; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -17781,7 +18332,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -17806,7 +18357,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -17816,14 +18367,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 /* PropertyAccessExpression */ + var left = node.kind === 158 /* PropertyAccessExpression */ ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { return false; } else { @@ -17839,7 +18390,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -17968,10 +18519,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else { + else if (node.kind !== 132 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18036,7 +18587,8 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174 /* SpreadElementExpression */) { + var arg = args[i]; + if (arg && arg.kind === 176 /* SpreadElementExpression */) { return i; } } @@ -18046,13 +18598,15 @@ var ts; var adjustedArgCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 160 /* TaggedTemplateExpression */) { + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 162 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172 /* TemplateExpression */) { + if (tagExpression.template.kind === 174 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -18069,11 +18623,16 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } + else if (node.kind === 132 /* Decorator */) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 159 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 161 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -18081,6 +18640,7 @@ var ts; // If we are missing the close paren, the call is incomplete. callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); } // If the user supplied type arguments, but the number of type arguments does not match // the declared number of type parameters, the call has an incorrect arity. @@ -18091,7 +18651,6 @@ var ts; } // If spread arguments are present, check that they correspond to a rest parameter. If so, no // further checking is necessary. - var spreadArgIndex = getSpreadArgumentIndex(args); if (spreadArgIndex >= 0) { return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1; } @@ -18123,7 +18682,7 @@ var ts; }); return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature, args, excludeArgument, context) { + function inferTypeArguments(node, signature, args, excludeArgument, context) { var typeParameters = signature.typeParameters; var inferenceMapper = createInferenceMapper(context); // Clear out all the inference results from the last time inferTypeArguments was called on this context @@ -18148,15 +18707,16 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. + if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); - var argType = void 0; - if (i === 0 && args[i].parent.kind === 160 /* TaggedTemplateExpression */) { - argType = globalTemplateStringsArrayType; - } - else { + var argType = getEffectiveArgumentType(node, i, arg); + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; @@ -18168,8 +18728,10 @@ var ts; // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) + // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. + // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { - for (var i = 0; i < args.length; i++) { + for (var i = 0; i < argCount; i++) { // No need to check for omitted args and template expressions, their exlusion value is always undefined if (excludeArgument[i] === false) { var arg = args[i]; @@ -18180,7 +18742,7 @@ var ts; } getInferredTypes(context); } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; for (var i = 0; i < typeParameters.length; i++) { @@ -18191,27 +18753,38 @@ var ts; if (typeArgumentsAreAssignable /* so far */) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); } } } return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. + if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); - // A tagged template expression provides a special first argument, and string literals get string literal types - // unless we're reporting errors - var argType = i === 0 && node.kind === 160 /* TaggedTemplateExpression */ - ? globalTemplateStringsArrayType - : arg.kind === 8 /* StringLiteral */ && !reportErrors + var argType = getEffectiveArgumentType(node, i, arg); + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { + argType = arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } // Use argument expression as error location when reporting errors - if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } } @@ -18223,50 +18796,277 @@ var ts; * * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution - * expressions, where the first element of the list is the template for error reporting purposes. + * expressions, where the first element of the list is `undefined`. + * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types + * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { var template = node.template; - args = [template]; - if (template.kind === 172 /* TemplateExpression */) { + args = [undefined]; + if (template.kind === 174 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } + else if (node.kind === 132 /* Decorator */) { + // For a decorator, we return undefined as we will determine + // the number and types of arguments for a decorator using + // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. + return undefined; + } else { args = node.arguments || emptyArray; } return args; } /** - * In a 'super' call, type arguments are not provided within the CallExpression node itself. - * Instead, they must be fetched from the class declaration's base type node. - * - * If 'node' is a 'super' call (e.g. super(...), new super(...)), then we attempt to fetch - * the type arguments off the containing class's first heritage clause (if one exists). Note that if - * type arguments are supplied on the 'super' call, they are ignored (though this is syntactically incorrect). - * - * In all other cases, the call's explicit type arguments are returned. - */ - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91 /* SuperKeyword */) { - var containingClass = ts.getAncestor(callExpression, 202 /* ClassDeclaration */); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 132 /* Decorator */) { + switch (node.parent.kind) { + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) + return 1; + case 134 /* PropertyDeclaration */: + // A property declaration decorator will have two arguments (see + // `PropertyDecorator` in core.d.ts) + return 2; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + // A method or accessor declaration decorator will have two or three arguments (see + // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If the method decorator signature only accepts a target and a key, we will only + // type check those arguments. + return signature.parameters.length >= 3 ? 3 : 2; + case 131 /* Parameter */: + // A parameter declaration decorator will have three arguments (see + // `ParameterDecorator` in core.d.ts) + return 3; + } } else { - // Ordinary case - simple function invocation. - return callExpression.typeArguments; + return args.length; } } - function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160 /* TaggedTemplateExpression */; + /** + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ + function getEffectiveDecoratorFirstArgumentType(node) { + // The first argument to a decorator is its `target`. + switch (node.kind) { + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // 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 131 /* Parameter */: + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. + node = node.parent; + if (node.kind === 137 /* Constructor */) { + var classSymbol_1 = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol_1); + } + // fall-through + case 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* 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: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ + function getEffectiveDecoratorSecondArgumentType(node) { + // The second argument to a decorator is its `propertyKey` + switch (node.kind) { + case 204 /* ClassDeclaration */: + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + case 131 /* Parameter */: + node = node.parent; + if (node.kind === 137 /* 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 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* 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 + // be either string or symbol. + var element = node; + switch (element.name.kind) { + case 65 /* Identifier */: + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + return getStringLiteralType(element.name); + case 129 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 2097152 /* ESSymbol */)) { + return nameType; + } + else { + return stringType; + } + default: + 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. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ + 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 204 /* ClassDeclaration */: + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + case 131 /* Parameter */: + // The `parameterIndex` for a parameter decorator is always a number + return numberType; + case 134 /* PropertyDeclaration */: + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` + // 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. + */ + function getEffectiveDecoratorArgumentType(node, argIndex) { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + /** + * Gets the effective argument type for an argument in a call expression. + */ + function getEffectiveArgumentType(node, argIndex, arg) { + // Decorators provide special arguments, a tagged template expression provides + // a special first argument, and string literals get string literal types + // unless we're reporting errors + if (node.kind === 132 /* Decorator */) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + return globalTemplateStringsArrayType; + } + // This is not a synthetic argument, so we return 'undefined' + // to signal that the caller needs to check the argument. + return undefined; + } + /** + * Gets the effective argument expression for an argument in a call expression. + */ + function getEffectiveArgument(node, args, argIndex) { + // For a decorator or the first argument of a tagged template expression we return undefined. + if (node.kind === 132 /* Decorator */ || + (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */)) { + return undefined; + } + return args[argIndex]; + } + /** + * Gets the error node to use when reporting errors for an effective argument. + */ + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 132 /* Decorator */) { + // For a decorator, we use the expression of the decorator for error reporting. + return node.expression; + } + else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 162 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 132 /* Decorator */; var typeArguments; - if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 91 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); @@ -18276,7 +19076,7 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -18291,13 +19091,20 @@ var ts; // // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. + // + // For a decorator, no arguments are susceptible to contextual typing due to the fact + // decorators are applied to a declaration by the emitter, and not to an expression. var excludeArgument; - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); + if (!isDecorator) { + // We do not need to call `getEffectiveArgumentCount` here as it only + // applies when calculating the number of arguments for a decorator. + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; } - excludeArgument[i] = true; } } // The following variables are captured and modified by calls to chooseOverload. @@ -18361,19 +19168,22 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } // No signature was applicable. We have already reported the errors for the invalid signature. // If this is a type resolution session, e.g. Language Service, try to get better information that anySignature. @@ -18389,6 +19199,14 @@ var ts; } } return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } function chooseOverload(candidates, relation) { for (var _i = 0; _i < candidates.length; _i++) { var originalCandidate = candidates[_i]; @@ -18409,7 +19227,7 @@ var ts; typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { - inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } @@ -18456,7 +19274,11 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -18568,6 +19390,47 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray); } + /** + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 131 /* Parameter */: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 134 /* PropertyDeclaration */: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + /** + * Resolves a decorator as if it were a call expression. + */ + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } // candidatesOutArray is passed by signature help in the language service, and collectCandidates // must fill it up with the appropriate candidate signatures function getResolvedSignature(node, candidatesOutArray) { @@ -18578,15 +19441,18 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158 /* CallExpression */) { + if (node.kind === 160 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159 /* NewExpression */) { + else if (node.kind === 161 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 162 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } + else if (node.kind === 132 /* Decorator */) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } else { ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); } @@ -18600,12 +19466,12 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { return voidType; } - if (node.kind === 159 /* NewExpression */) { + if (node.kind === 161 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 /* Constructor */ && - declaration.kind !== 140 /* ConstructSignature */ && - declaration.kind !== 144 /* ConstructorType */) { + declaration.kind !== 137 /* Constructor */ && + declaration.kind !== 141 /* ConstructSignature */ && + declaration.kind !== 146 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -18653,7 +19519,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180 /* Block */) { + if (func.body.kind !== 182 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -18733,7 +19599,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 198 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -18748,7 +19614,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182 /* Block */) { return; } var bodyBlock = func.body; @@ -18766,11 +19632,11 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163 /* FunctionExpression */) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165 /* FunctionExpression */) { + checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -18801,14 +19667,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -18821,7 +19687,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180 /* Block */) { + if (node.body.kind === 182 /* Block */) { checkSourceElement(node.body); } else { @@ -18829,7 +19695,7 @@ var ts; if (node.type) { checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); } - checkFunctionExpressionBodies(node.body); + checkFunctionAndClassExpressionBodies(node.body); } } } @@ -18863,17 +19729,17 @@ var ts; // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -18882,11 +19748,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; } - case 157 /* ElementAccessExpression */: { + case 159 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { @@ -18896,7 +19762,7 @@ var ts; } return false; } - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -18913,13 +19779,7 @@ var ts; return true; } function checkDeleteExpression(node) { - // Grammar checking - if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 65 /* Identifier */) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -18931,13 +19791,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator - if ((node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33 /* PlusToken */: @@ -18961,11 +19814,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -19047,7 +19895,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_12 = p.name; var type = isTypeAny(sourceType) @@ -19076,8 +19924,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19102,7 +19950,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 172 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19115,14 +19963,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154 /* ArrayLiteralExpression */) { + if (target.kind === 156 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19135,14 +19983,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - // Grammar checking - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { + if (operator === 53 /* EqualsToken */ && (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -19317,7 +20159,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 /* ClassDeclaration */ || current.kind === 175 /* ClassExpression */) { + else if (ts.isClassLike(current)) { return true; } current = parent; @@ -19393,7 +20235,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -19404,7 +20246,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -19425,10 +20267,6 @@ var ts; } return type; } - function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in @@ -19436,9 +20274,9 @@ var ts; // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpressionOrQualifiedName(node, contextualMapper) { + function checkExpression(node, contextualMapper) { var type; - if (node.kind == 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -19450,9 +20288,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -19479,61 +20317,60 @@ var ts; return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return checkCallExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return checkClassExpression(node); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return checkDeleteExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return checkVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return undefinedType; - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return checkYieldExpression(node); } return unknownType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); @@ -19550,15 +20387,13 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -19575,33 +20410,107 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 /* MethodDeclaration */ || - node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */; + return node.kind === 136 /* MethodDeclaration */ || + node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 /* Identifier */ && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166 /* ArrowFunction */: + case 140 /* CallSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 145 /* FunctionType */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 /* FunctionType */ || node.kind === 201 /* FunctionDeclaration */ || node.kind === 144 /* ConstructorType */ || - node.kind === 139 /* CallSignature */ || node.kind === 136 /* Constructor */ || - node.kind === 140 /* ConstructSignature */) { + else if (node.kind === 145 /* FunctionType */ || node.kind === 203 /* FunctionDeclaration */ || node.kind === 146 /* ConstructorType */ || + node.kind === 140 /* CallSignature */ || node.kind === 137 /* Constructor */ || + node.kind === 141 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143 /* TypePredicate */) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 /* ObjectBindingPattern */ || + param.name.kind === 154 /* ArrayBindingPattern */) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 /* Identifier */ && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 /* ArrayBindingPattern */ || + element.name.kind === 153 /* ObjectBindingPattern */) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -19629,7 +20538,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203 /* InterfaceDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -19649,7 +20558,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -19657,7 +20566,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -19701,17 +20610,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 160 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 155 /* ObjectLiteralExpression */: return false; + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -19719,12 +20628,12 @@ var ts; if (n.kind === 93 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 /* FunctionExpression */ && n.kind !== 201 /* FunctionDeclaration */) { + else if (n.kind !== 165 /* FunctionExpression */ && n.kind !== 203 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 /* PropertyDeclaration */ && + return n.kind === 134 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -19741,7 +20650,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -19759,7 +20668,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137 /* GetAccessor */) { + if (node.kind === 138 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -19767,7 +20676,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 137 /* GetAccessor */ ? 138 /* SetAccessor */ : 137 /* GetAccessor */; + var otherKind = node.kind === 138 /* GetAccessor */ ? 139 /* SetAccessor */ : 138 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -19791,28 +20700,27 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { - // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -19864,9 +20772,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 /* CallSignature */ || signatureDeclarationNode.kind === 140 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 139 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 /* CallSignature */ || signatureDeclarationNode.kind === 141 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 140 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -19884,7 +20792,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -19967,7 +20875,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */); + ts.Debug.assert(node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -19996,7 +20904,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 /* InterfaceDeclaration */ || node.parent.kind === 146 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 /* InterfaceDeclaration */ || node.parent.kind === 148 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -20007,7 +20915,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 201 /* FunctionDeclaration */ || node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */ || node.kind === 136 /* Constructor */) { + if (node.kind === 203 /* FunctionDeclaration */ || node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */ || node.kind === 137 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20130,16 +21038,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -20151,43 +21059,51 @@ var ts; } /** Check a decorator */ function checkDecorator(node) { - var expression = node.expression; - var exprType = checkExpression(expression); + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1 /* Any */) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); - checkTypeAssignableTo(exprType, classDecoratorType, node); + expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 133 /* PropertyDeclaration */: - checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); + case 131 /* Parameter */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); - checkTypeAssignableTo(exprType, methodDecoratorType, node); - break; - case 130 /* Parameter */: - checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); break; } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node) { // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 142 /* TypeReference */) { + if (node && node.kind === 144 /* TypeReference */) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } @@ -20197,19 +21113,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 130 /* Parameter */: + case 131 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -20238,47 +21154,44 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 138 /* SetAccessor */: - case 137 /* GetAccessor */: - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 139 /* SetAccessor */: + case 138 /* GetAccessor */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130 /* Parameter */) { + if (node.kind === 131 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 129 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -20322,12 +21235,12 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207 /* ModuleBlock */) { - checkFunctionExpressionBodies(node); + if (ts.isFunctionBlock(node) || node.kind === 209 /* ModuleBlock */) { + checkFunctionAndClassExpressionBodies(node); } } function checkCollisionWithArgumentsInGeneratedCode(node) { @@ -20345,12 +21258,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 /* PropertyDeclaration */ || - node.kind === 132 /* PropertySignature */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */) { + if (node.kind === 134 /* PropertyDeclaration */ || + node.kind === 133 /* PropertySignature */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -20359,7 +21272,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -20392,7 +21305,7 @@ var ts; return; } // bubble up and find containing type - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClass = ts.getContainingClass(node); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; @@ -20412,12 +21325,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 208 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 228 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 230 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -20452,7 +21365,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 199 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 201 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -20462,17 +21375,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 181 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 183 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 180 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 207 /* ModuleBlock */ || - container.kind === 206 /* ModuleDeclaration */ || - container.kind === 228 /* SourceFile */); + (container.kind === 182 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 209 /* ModuleBlock */ || + container.kind === 208 /* ModuleDeclaration */ || + container.kind === 230 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -20487,7 +21400,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 131 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -20498,7 +21411,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 131 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -20518,14 +21431,13 @@ var ts; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -20536,7 +21448,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 130 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -20568,10 +21480,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 /* PropertyDeclaration */ && node.kind !== 132 /* PropertySignature */) { + if (node.kind !== 134 /* PropertyDeclaration */ && node.kind !== 133 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -20601,7 +21513,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 /* Block */ || node.kind === 155 /* ObjectLiteralExpression */) { + if (node.kind === 182 /* Block */ || node.kind === 157 /* ObjectLiteralExpression */) { return true; } node = node.parent; @@ -20634,12 +21546,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -20659,14 +21571,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -20695,7 +21607,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -20709,7 +21621,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -20948,7 +21860,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138 /* SetAccessor */))); + return !!(node.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -20961,7 +21873,8 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { // A generator does not need its return expressions checked against its return type. @@ -20970,27 +21883,22 @@ var ts; // for generators. return; } - if (func.kind === 138 /* SetAccessor */) { + if (func.kind === 139 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136 /* Constructor */) { + else if (func.kind === 137 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1 /* StrictMode */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -21002,7 +21910,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 222 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 224 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21014,7 +21922,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 223 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -21035,7 +21943,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 197 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -21083,9 +21991,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -21105,7 +22010,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 202 /* ClassDeclaration */) { + if (type.flags & 1024 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -21143,7 +22048,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 128 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21194,16 +22099,17 @@ var ts; } } function checkClassExpression(node) { - grammarErrorOnNode(node, ts.Diagnostics.class_expressions_are_not_currently_supported); - ts.forEach(node.members, checkSourceElement); - return unknownType; + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); - // Grammar checking if (!node.name && !(node.flags & 256 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); checkDecorators(node); if (node.name) { @@ -21218,36 +22124,42 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455 /* Value */)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - // Check that base type can be evaluated as expression - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -21262,7 +22174,6 @@ var ts; } }); } - ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -21335,7 +22246,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 /* GetAccessor */ || kind === 138 /* SetAccessor */; + return kind === 138 /* GetAccessor */ || kind === 139 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -21399,13 +22310,13 @@ var ts; } function checkInterfaceDeclaration(node) { // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -21427,7 +22338,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -21449,7 +22360,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -21489,7 +22400,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -21500,7 +22411,7 @@ var ts; case 47 /* TildeToken */: return ~value; } return undefined; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -21525,11 +22436,11 @@ var ts; return undefined; case 7 /* NumericLiteral */: return +e.text; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return evalConstant(e.expression); case 65 /* Identifier */: - case 157 /* ElementAccessExpression */: - case 156 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 158 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -21542,7 +22453,7 @@ var ts; } else { var expression; - if (e.kind === 157 /* ElementAccessExpression */) { + if (e.kind === 159 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -21560,7 +22471,7 @@ var ts; if (current.kind === 65 /* Identifier */) { break; } - else if (current.kind === 156 /* PropertyAccessExpression */) { + else if (current.kind === 158 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -21599,7 +22510,7 @@ var ts; return; } // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -21629,7 +22540,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 205 /* EnumDeclaration */) { + if (declaration.kind !== 207 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -21652,8 +22563,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 201 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 203 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -21676,7 +22587,15 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -21701,14 +22620,14 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 202 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 204 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; } } // Checks for ambient external modules. - if (node.name.kind === 8 /* StringLiteral */) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -21721,10 +22640,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { node = node.left; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -21740,9 +22659,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -21765,7 +22684,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 /* ExportSpecifier */ ? + var message = node.kind === 220 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -21778,7 +22697,11 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -21788,7 +22711,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -21799,7 +22722,11 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1 /* Export */) { @@ -21829,6 +22756,10 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + // If we hit an export in an illegal context, just bail out to avoid cascading errors. + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } @@ -21837,8 +22768,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -21851,6 +22782,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 /* SourceFile */ && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 208 /* ModuleDeclaration */) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -21858,8 +22794,12 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 206 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. + return; + } + var container = node.parent.kind === 230 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 208 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -21886,10 +22826,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228 /* SourceFile */) { + if (node.kind === 230 /* SourceFile */) { return node.statements; } - if (node.kind === 206 /* ModuleDeclaration */ && node.body.kind === 207 /* ModuleBlock */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.body.kind === 209 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -21914,116 +22854,123 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return checkTypeParameter(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return checkParameter(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return checkPropertyDeclaration(node); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return checkSignatureDeclaration(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return checkMethodDeclaration(node); - case 136 /* Constructor */: + case 137 /* Constructor */: return checkConstructorDeclaration(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return checkAccessorDeclaration(node); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return checkTypeReferenceNode(node); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return checkTypePredicate(node); + case 147 /* TypeQuery */: return checkTypeQuery(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return checkTypeLiteral(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return checkArrayType(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return checkTupleType(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return checkUnionType(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return checkSourceElement(node.type); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return checkBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return checkVariableStatement(node); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return checkExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return checkIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return checkDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return checkWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return checkForStatement(node); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return checkForInStatement(node); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return checkForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return checkReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return checkWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return checkSwitchStatement(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return checkLabeledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return checkThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return checkTryStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return checkBindingElement(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return checkClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return checkImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return checkExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return checkExportAssignment(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return checkMissingDeclaration(node); } } - // Function expression bodies are checked after all statements in the enclosing body. This is to ensure - // constructs like the following are permitted: + // Function and class expression bodies are checked after all statements in the enclosing body. This is + // to ensure constructs like the following are permitted: // let foo = function () { // let s = foo(); // return "hello"; @@ -22031,86 +22978,89 @@ var ts; // Here, performing a full type check of the body of the function expression whilst in the process of // determining the type of foo would cause foo to be given type any because of the recursive reference. // Delaying the type check of the body ensures foo has been assigned a type. - function checkFunctionExpressionBodies(node) { + function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - ts.forEach(node.decorators, checkFunctionExpressionBodies); - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 177 /* ClassExpression */: + ts.forEach(node.members, checkSourceElement); + break; + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 193 /* WithStatement */: - checkFunctionExpressionBodies(node.expression); + case 195 /* WithStatement */: + checkFunctionAndClassExpressionBodies(node.expression); break; - case 131 /* Decorator */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 153 /* BindingElement */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 225 /* PropertyAssignment */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 172 /* TemplateExpression */: - case 178 /* TemplateSpan */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 208 /* CaseBlock */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: - case 199 /* VariableDeclaration */: - case 200 /* VariableDeclarationList */: - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 215 /* ExportAssignment */: - case 228 /* SourceFile */: - ts.forEachChild(node, checkFunctionExpressionBodies); + case 132 /* Decorator */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 155 /* BindingElement */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 174 /* TemplateExpression */: + case 180 /* TemplateSpan */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 210 /* CaseBlock */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: + case 201 /* VariableDeclaration */: + case 202 /* VariableDeclarationList */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 217 /* ExportAssignment */: + case 230 /* SourceFile */: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } } @@ -22123,6 +23073,11 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } // Grammar checking checkGrammarSourceFile(node); emitExtends = false; @@ -22130,7 +23085,7 @@ var ts; emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); - checkFunctionExpressionBodies(node); + checkFunctionAndClassExpressionBodies(node); if (ts.isExternalModule(node)) { checkExternalModuleExports(node); } @@ -22172,7 +23127,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 195 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -22195,23 +23150,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 177 /* ClassExpression */: + if (location.name) { + copySymbol(location.symbol, meaning); + } + // Fall through + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -22240,80 +23200,45 @@ var ts; } } } - if (isInsideWithStatementBody(location)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return []; - } - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 228 /* SourceFile */: - if (!ts.isExternalModule(location)) - break; - case 206 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); - break; - case 205 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); - break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); - } - break; - case 163 /* FunctionExpression */: - if (location.name) { - copySymbol(location.symbol, meaning); - } - break; - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 /* Identifier */ && + return name.kind === 65 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129 /* TypeParameter */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 130 /* TypeParameter */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127 /* QualifiedName */) { + while (node.parent && node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 142 /* TypeReference */; + return node.parent && node.parent.kind === 144 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 158 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 179 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 128 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 211 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 217 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22325,11 +23250,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215 /* ExportAssignment */) { + if (entityName.parent.kind === 217 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 156 /* PropertyAccessExpression */) { + if (entityName.kind !== 158 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -22339,7 +23264,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 179 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } @@ -22354,14 +23279,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156 /* PropertyAccessExpression */) { + else if (entityName.kind === 158 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127 /* QualifiedName */) { + else if (entityName.kind === 128 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -22370,12 +23295,15 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 144 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } + if (entityName.parent.kind === 143 /* TypePredicate */) { + return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + } // Do we want to return undefined here? return undefined; } @@ -22389,14 +23317,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 /* ExportAssignment */ + return node.parent.kind === 217 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: @@ -22405,7 +23333,7 @@ var ts; case 114 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 137 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -22414,14 +23342,14 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 /* ImportDeclaration */ || node.parent.kind === 216 /* ExportDeclaration */) && + ((node.parent.kind === 212 /* ImportDeclaration */ || node.parent.kind === 218 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Intentional fall-through case 7 /* NumericLiteral */: // index access - if (node.parent.kind == 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -22438,7 +23366,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 226 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 228 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -22454,6 +23382,11 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration var symbol = getSymbolOfNode(node); @@ -22485,6 +23418,16 @@ var ts; } return checkExpression(expr); } + /** + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 /* Static */ + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } // Return the list of properties of the given type, augmented with properties from Function // if the type has call or construct signatures function getAugmentedPropertiesOfType(type) { @@ -22517,93 +23460,92 @@ var ts; return [symbol]; } // Emitter support - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228 /* SourceFile */; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - // If this is es6 or higher, just use the name of the export - // no need to qualify it. - if (languageVersion >= 2 /* ES6 */) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211 /* ImportClause */) { - var defaultKeyword; - if (languageVersion === 0 /* ES3 */) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214 /* ImportSpecifier */) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - // 1. If this is es6 or higher, just use the name of the export - // no need to qualify it. - // 2. export mechanism for System modules is different from CJS\AMD - // and it does not need qualifications for exports - if (languageVersion >= 2 /* ES6 */ || compilerOptions.module === 4 /* System */) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 /* ModuleDeclaration */ || node.kind === 205 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration + // node of the exported entity's container. Otherwise, return undefined. + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - // Whan an identifier resolves to a parented symbol, it references an exported entity from - // another declaration of the same internal module. - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576 /* ExportValue */) { + // If we reference an exported entity within the same module declaration, then whether + // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the + // kinds that we do NOT prefix. + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944 /* ExportHasLocal */) { + return undefined; + } + symbol = exportSymbol; } - // If we reference an exported entity within the same module declaration, then whether - // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the - // kinds that we do NOT prefix. - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - // Named imports from ES6 import declarations are rewritten - if (symbol.flags & 8388608 /* Alias */) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 230 /* SourceFile */) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 /* ModuleDeclaration */ || n.kind === 207 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + // When resolved as an expression identifier, if the given node references an import, return the declaration of + // that import. Otherwise, return undefined. + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182 /* Block */: + case 210 /* CaseBlock */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418 /* BlockScoped */) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + // When resolved as an expression identifier, if the given node references a nested block scoped entity with + // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an + // existing name. + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -22661,7 +23603,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227 /* EnumMember */) { + if (node.kind === 229 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -22674,10 +23616,13 @@ var ts; return undefined; } /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65 /* Identifier */) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it + // here has no effect anyway as an identifier in a type name is not an expression. + // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); + // var text = substitution || (node).text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -22686,15 +23631,15 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { // serialization of a TypeReferenceNode uses the following rules: // // * The serialized type of a TypeReference that is `void` is "void 0". @@ -22727,11 +23672,11 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; @@ -22739,7 +23684,7 @@ var ts; return "Object"; } /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { // serialization of a TypeNode uses the following rules: // // * The serialized type of `void` is "void 0" (undefined). @@ -22754,26 +23699,26 @@ var ts; switch (node.kind) { case 99 /* VoidKeyword */: return "void 0"; - case 150 /* ParenthesizedType */: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 152 /* ParenthesizedType */: + return serializeTypeNode(node.type); + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return "Function"; - case 147 /* ArrayType */: - case 148 /* TupleType */: + case 149 /* ArrayType */: + case 150 /* TupleType */: return "Array"; case 113 /* BooleanKeyword */: return "Boolean"; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: case 8 /* StringLiteral */: return "String"; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return "Number"; - case 142 /* TypeReference */: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145 /* TypeQuery */: - case 146 /* TypeLiteral */: - case 149 /* UnionType */: + case 144 /* TypeReference */: + return serializeTypeReferenceNode(node); + case 147 /* TypeQuery */: + case 148 /* TypeLiteral */: + case 151 /* UnionType */: case 112 /* AnyKeyword */: break; default: @@ -22784,7 +23729,7 @@ var ts; return "Object"; } /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { // serialization of the type of a declaration uses the following rules: // // * The serialized type of a ClassDeclaration is "Function" @@ -22796,11 +23741,11 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 202 /* ClassDeclaration */: return "Function"; - case 133 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204 /* ClassDeclaration */: return "Function"; + case 134 /* PropertyDeclaration */: return serializeTypeNode(node.type); + case 131 /* Parameter */: return serializeTypeNode(node.type); + case 138 /* GetAccessor */: return serializeTypeNode(node.type); + case 139 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; @@ -22808,7 +23753,7 @@ var ts; return "void 0"; } /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. @@ -22817,7 +23762,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -22832,19 +23777,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147 /* ArrayType */) { + if (parameterType.kind === 149 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -22854,9 +23799,9 @@ var ts; return emptyArray; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -22879,25 +23824,25 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455 /* Value */, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, + /*nodeNotFoundMessage*/ undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 /* BindingElement */ || (n.parent.kind === 199 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 /* BindingElement */ || (n.parent.kind === 201 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 224 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 226 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -22919,7 +23864,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -22933,7 +23881,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -22966,10 +23913,7 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -22994,137 +23938,6 @@ var ts; anyArrayType = createArrayType(anyType); } // GRAMMAR CHECKING - function isReservedWordInStrictMode(node) { - // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word - return (node.parserContextFlags & 1 /* StrictMode */) && - (102 /* FirstFutureReservedWord */ <= node.originalKeywordKind && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) - // if so, we would like to give more explicit invalid usage error. - if (ts.getAncestor(identifier, 202 /* ClassDeclaration */) || ts.getAncestor(identifier, 175 /* ClassExpression */)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - // Check if the import declaration used strict-mode reserved word in its names bindings - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212 /* NamespaceImport */) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213 /* NamedImports */) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 /* Identifier */ && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 201 /* FunctionDeclaration */: - case 129 /* TypeParameter */: - case 153 /* BindingElement */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - return checkGrammarIdentifierInStrictMode(name); - case 202 /* ClassDeclaration */: - // Report an error if the class declaration uses strict-mode reserved word. - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206 /* ModuleDeclaration */: - // Report an error if the module declaration uses strict-mode reserved word. - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209 /* ImportEqualsDeclaration */: - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - // Check if the type reference is using strict mode keyword - // Example: - // class C { - // foo(x: public){} // Error. - // } - if (typeName.kind === 65 /* Identifier */) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127 /* QualifiedName */) { - // Walk from right to left and report a possible error at each Identifier in QualifiedName - // Example: - // x1: public.private.package // error at public and private - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - // This function will report an error for every identifier in property access expression - // whether it violates strict mode reserved words. - // Example: - // public // error at public - // public.private.package // error at public - // B.private.B // no error - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - // Example: - // class C extends public // error at public - if (expression && expression.kind === 65 /* Identifier */) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156 /* PropertyAccessExpression */) { - // Walk from left to right in PropertyAccessExpression until we are at the left most expression - // in PropertyAccessExpression. According to grammar production of MemberExpression, - // the left component expression is a PrimaryExpression (i.e. Identifier) while the other - // component after dots can be IdentifierName. - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - // The function takes an identifier when uses as a typeName in TypeReferenceNode - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -23135,7 +23948,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 /* GetAccessor */ || node.kind === 138 /* SetAccessor */) { + else if (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -23145,33 +23958,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 206 /* ModuleDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 130 /* Parameter */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 208 /* ModuleDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 131 /* Parameter */: break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 204 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 206 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70 /* ConstKeyword */) && - node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23207,7 +24020,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -23216,10 +24029,10 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; @@ -23232,10 +24045,10 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -23244,13 +24057,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -23258,7 +24071,7 @@ var ts; break; } } - if (node.kind === 136 /* Constructor */) { + if (node.kind === 137 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -23269,10 +24082,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -23336,7 +24149,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164 /* ArrowFunction */) { + if (node.kind === 166 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23371,7 +24184,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 /* StringKeyword */ && parameter.type.kind !== 120 /* NumberKeyword */) { + if (parameter.type.kind !== 123 /* StringKeyword */ && parameter.type.kind !== 121 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -23404,7 +24217,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176 /* OmittedExpression */) { + if (arg.kind === 178 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23478,19 +24291,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 128 /* ComputedPropertyName */) { + if (node.kind !== 129 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 172 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -23502,10 +24315,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -23517,14 +24326,13 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 /* OmittedExpression */ || - name_17.kind === 128 /* ComputedPropertyName */) { + var name_15 = prop.name; + if (prop.kind === 178 /* OmittedExpression */ || + name_15.kind === 129 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_17); + checkGrammarComputedPropertyName(name_15); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -23536,46 +24344,44 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 225 /* PropertyAssignment */ || prop.kind === 226 /* ShorthandPropertyAssignment */) { + if (prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135 /* MethodDeclaration */) { + else if (prop.kind === 136 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 137 /* GetAccessor */) { + else if (prop.kind === 138 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 138 /* SetAccessor */) { + else if (prop.kind === 139 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -23584,24 +24390,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -23624,10 +24430,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 138 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138 /* SetAccessor */) { + else if (kind === 139 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -23652,7 +24458,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -23662,7 +24468,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155 /* ObjectLiteralExpression */) { + if (node.parent.kind === 157 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23670,7 +24476,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23686,22 +24492,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return true; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -23713,11 +24519,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 190 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 192 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -23725,8 +24531,8 @@ var ts; return false; } break; - case 194 /* SwitchStatement */: - if (node.kind === 191 /* BreakStatement */ && !node.label) { + case 196 /* SwitchStatement */: + if (node.kind === 193 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -23741,13 +24547,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -23759,7 +24565,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) { + if (node.name.kind === 154 /* ArrayBindingPattern */ || node.name.kind === 153 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -23767,12 +24573,9 @@ var ts; return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 /* ForInStatement */ && node.parent.parent.kind !== 189 /* ForOfStatement */) { + if (node.parent.parent.kind !== 190 /* ForInStatement */ && node.parent.parent.kind !== 191 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -23796,8 +24599,7 @@ var ts; // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65 /* Identifier */) { @@ -23809,7 +24611,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -23826,15 +24628,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return false; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -23850,7 +24652,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168 /* PrefixUnaryExpression */) { + if (expression.kind === 170 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; @@ -23879,7 +24681,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -23921,26 +24723,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65 /* Identifier */) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -23952,18 +24734,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (ts.isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -23983,11 +24765,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 203 /* InterfaceDeclaration */ || - node.kind === 210 /* ImportDeclaration */ || - node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 216 /* ExportDeclaration */ || - node.kind === 215 /* ExportAssignment */ || + if (node.kind === 205 /* InterfaceDeclaration */ || + node.kind === 212 /* ImportDeclaration */ || + node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 218 /* ExportDeclaration */ || + node.kind === 217 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 256 /* Default */))) { return false; @@ -23997,7 +24779,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 183 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24023,7 +24805,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 180 /* Block */ || node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + if (node.parent.kind === 182 /* Block */ || node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -24036,13 +24818,8 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 16384 /* OctalLiteral */) { - if (node.parserContextFlags & 1 /* StrictMode */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -24053,8 +24830,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -24113,7 +24888,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 212 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -24189,10 +24964,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199 /* VariableDeclaration */) { + if (declaration.kind === 201 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 /* NamedImports */ || declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 211 /* ImportClause */) { + else if (declaration.kind === 215 /* NamedImports */ || declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 213 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24210,7 +24985,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 212 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -24220,12 +24995,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24318,41 +25093,41 @@ var ts; function emitType(type) { switch (type.kind) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return emitTypeReference(type); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return emitTypeQuery(type); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return emitArrayType(type); - case 148 /* TupleType */: + case 150 /* TupleType */: return emitTupleType(type); - case 149 /* UnionType */: + case 151 /* UnionType */: return emitUnionType(type); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return emitParenType(type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return emitTypeLiteral(type); case 65 /* Identifier */: return emitEntityName(type); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitEntityName(type); } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 209 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 211 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -24360,8 +25135,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 127 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 128 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 128 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -24370,7 +25145,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 156 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 158 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -24436,9 +25211,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -24482,10 +25257,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 /* ImportEqualsDeclaration */ || - (node.parent.kind === 228 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 /* ImportEqualsDeclaration */ || + (node.parent.kind === 230 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -24495,7 +25270,7 @@ var ts; }); } else { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -24513,23 +25288,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return writeVariableStatement(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return writeClassDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -24545,7 +25320,7 @@ var ts; if (node.flags & 256 /* Default */) { write("default "); } - else if (node.kind !== 203 /* InterfaceDeclaration */) { + else if (node.kind !== 205 /* InterfaceDeclaration */) { write("declare "); } } @@ -24591,7 +25366,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -24619,7 +25394,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -24670,9 +25445,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207 /* ModuleBlock */) { + while (node.body.kind !== 209 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -24733,7 +25513,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 136 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -24744,15 +25524,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 146 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 135 /* MethodDeclaration */ || - node.parent.kind === 134 /* MethodSignature */ || - node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.kind === 139 /* CallSignature */ || - node.parent.kind === 140 /* ConstructSignature */); + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 148 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 136 /* MethodDeclaration */ || + node.parent.kind === 135 /* MethodSignature */ || + node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.kind === 140 /* CallSignature */ || + node.parent.kind === 141 /* ConstructSignature */); emitType(node.constraint); } else { @@ -24763,31 +25543,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -24818,7 +25598,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -24899,7 +25679,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 199 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -24909,10 +25689,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && node.parent.kind === 146 /* TypeLiteral */) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && node.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -24921,14 +25701,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) { + else if (node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -24937,7 +25717,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24969,7 +25749,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { elements.push(element); } } @@ -25039,7 +25819,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 137 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25052,7 +25832,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 /* GetAccessor */ + return accessor.kind === 138 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -25061,7 +25841,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 139 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -25111,17 +25891,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135 /* MethodDeclaration */) { + else if (node.kind === 136 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136 /* Constructor */) { + else if (node.kind === 137 /* Constructor */) { write("constructor"); } else { @@ -25139,11 +25919,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 140 /* ConstructSignature */ || node.kind === 144 /* ConstructorType */) { + if (node.kind === 141 /* ConstructSignature */ || node.kind === 146 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("["); } else { @@ -25153,22 +25933,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 143 /* FunctionType */ || node.kind === 144 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 145 /* FunctionType */ || node.kind === 146 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 137 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25179,26 +25959,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25206,7 +25986,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25220,7 +26000,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25255,9 +26035,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.parent.kind === 146 /* TypeLiteral */) { + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -25273,24 +26053,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25298,7 +26078,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25311,7 +26091,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25323,12 +26103,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 151 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 153 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 154 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25347,7 +26127,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176 /* OmittedExpression */) { + if (bindingElement.kind === 178 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -25356,7 +26136,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 153 /* BindingElement */) { + else if (bindingElement.kind === 155 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -25397,40 +26177,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 203 /* InterfaceDeclaration */: - case 202 /* ClassDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 203 /* FunctionDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 205 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return writeFunctionDeclaration(node); - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessorDeclaration(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return emitPropertyDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFile(node); } } @@ -25491,7 +26271,7 @@ var ts; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function @@ -25567,7 +26347,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -25647,9 +26426,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -25672,73 +26451,44 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65 /* Identifier */) { - var name_20 = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65 /* Identifier */) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForClassExpression() { + return makeUniqueName("class"); } function generateNameForNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206 /* ModuleDeclaration */: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205 /* EnumDeclaration */: - generateNameForModuleOrEnum(node); - break; - case 210 /* ImportDeclaration */: - generateNameForImportDeclaration(node); - break; - case 216 /* ExportDeclaration */: - generateNameForExportDeclaration(node); - break; - case 215 /* ExportAssignment */: - generateNameForExportAssignment(node); - break; + case 65 /* Identifier */: + return makeUniqueName(node.text); + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 212 /* ImportDeclaration */: + case 218 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 217 /* ExportAssignment */: + return generateNameForExportDefault(); + case 177 /* ClassExpression */: + return generateNameForClassExpression(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; // The directory in which sourcemap will be @@ -25767,7 +26517,7 @@ var ts; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { // Emit comma to separate the entry if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; @@ -25836,8 +26586,8 @@ var ts; var emittedColumn = writer.getColumn(); // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -25903,8 +26653,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128 /* ComputedPropertyName */) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -25922,21 +26672,21 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */ || - node.kind === 206 /* ModuleDeclaration */ || - node.kind === 202 /* ClassDeclaration */ || - node.kind === 205 /* EnumDeclaration */) { + else if (node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */ || + node.kind === 208 /* ModuleDeclaration */ || + node.kind === 204 /* ClassDeclaration */ || + node.kind === 207 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_22 = node.name; + var name_19 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 128 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) + scopeName = name_19.kind === 129 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -26040,19 +26790,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228 /* SourceFile */) { + if (node.kind !== 230 /* SourceFile */) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -26308,10 +27058,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 172 /* TemplateExpression */) { + if (node.template.kind === 174 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 172 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26346,7 +27096,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 162 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 164 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -26388,11 +27138,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent.expression === template; - case 160 /* TaggedTemplateExpression */: - case 162 /* ParenthesizedExpression */: + case 162 /* TaggedTemplateExpression */: + case 164 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -26413,7 +27163,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 35 /* AsteriskToken */: case 36 /* SlashToken */: @@ -26425,8 +27175,8 @@ var ts; default: return -1 /* LessThan */; } - case 173 /* YieldExpression */: - case 171 /* ConditionalExpression */: + case 175 /* YieldExpression */: + case 173 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -26441,11 +27191,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153 /* BindingElement */); + ts.Debug.assert(node.kind !== 155 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 128 /* ComputedPropertyName */) { + else if (node.kind === 129 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -26486,75 +27236,126 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - return parent.name === node; - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: - return parent.name === node || parent.propertyName === node; - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 215 /* ExportAssignment */: - return false; - case 195 /* LabeledStatement */: - return node.parent.label === node; + case 156 /* ArrayLiteralExpression */: + case 172 /* BinaryExpression */: + case 160 /* CallExpression */: + case 223 /* CaseClause */: + case 129 /* ComputedPropertyName */: + case 173 /* ConditionalExpression */: + case 132 /* Decorator */: + case 167 /* DeleteExpression */: + case 187 /* DoStatement */: + case 159 /* ElementAccessExpression */: + case 217 /* ExportAssignment */: + case 185 /* ExpressionStatement */: + case 179 /* ExpressionWithTypeArguments */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 186 /* IfStatement */: + case 161 /* NewExpression */: + case 164 /* ParenthesizedExpression */: + case 171 /* PostfixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: + case 194 /* ReturnStatement */: + case 228 /* ShorthandPropertyAssignment */: + case 176 /* SpreadElementExpression */: + case 196 /* SwitchStatement */: + case 162 /* TaggedTemplateExpression */: + case 180 /* TemplateSpan */: + case 198 /* ThrowStatement */: + case 163 /* TypeAssertionExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 175 /* YieldExpression */: + return true; + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 201 /* VariableDeclaration */: + return parent.initializer === node; + case 158 /* PropertyAccessExpression */: + return parent.expression === node; + case 166 /* ArrowFunction */: + case 165 /* FunctionExpression */: + return parent.body === node; + case 211 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 128 /* QualifiedName */: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230 /* SourceFile */) { + // Identifier references module export + if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 201 /* VariableDeclaration */: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -26595,7 +27396,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -26626,11 +27427,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: - case 154 /* ArrayLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: + case 156 /* ArrayLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -26650,17 +27451,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174 /* SpreadElementExpression */) { + if (e.kind === 176 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 176 /* SpreadElementExpression */) { i++; } write("["); @@ -26683,7 +27484,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174 /* SpreadElementExpression */; + return node.kind === 176 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -26753,7 +27554,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 /* GetAccessor */ || property.kind === 138 /* SetAccessor */) { + if (property.kind === 138 /* GetAccessor */ || property.kind === 139 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -26805,13 +27606,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225 /* PropertyAssignment */) { + if (property.kind === 227 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 226 /* ShorthandPropertyAssignment */) { + else if (property.kind === 228 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135 /* MethodDeclaration */) { + else if (property.kind === 136 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -26845,7 +27646,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128 /* ComputedPropertyName */) { + if (properties[i].name.kind === 129 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -26861,21 +27662,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(172 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(158 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(159 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -26883,7 +27684,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 161 /* TypeAssertionExpression */) { + while (expr.kind === 163 /* TypeAssertionExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -26895,11 +27696,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 /* NewExpression */ && + expr.kind !== 161 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(164 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -26912,46 +27713,39 @@ var ts; if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2 /* ES6 */) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230 /* SourceFile */; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // export let obj = { y }; - // } - // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (languageVersion < 2 /* ES6 */) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - // Emit identifier as an identifier - write(": "); - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -26963,7 +27757,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -26997,7 +27791,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -27015,10 +27809,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 176 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 162 /* ParenthesizedExpression */ || node.kind === 161 /* TypeAssertionExpression */) { + while (node.kind === 164 /* ParenthesizedExpression */ || node.kind === 163 /* TypeAssertionExpression */) { node = node.expression; } return node; @@ -27039,13 +27833,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157 /* ElementAccessExpression */) { + else if (expr.kind === 159 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -27090,7 +27884,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 158 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -27109,23 +27903,21 @@ var ts; } function emitNewExpression(node) { write("new "); - // Spread operator logic can be supported in new expressions in ES5 using a combination + // Spread operator logic is supported in new expressions in ES5 using a combination // of Function.prototype.bind() and Function.prototype.apply(). // // Example: // - // var arguments = [1, 2, 3, 4, 5]; - // new Array(...arguments); + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); // - // Could be transpiled into ES5: + // is compiled into the following ES5: // - // var arguments = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(arguments))); + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); // - // `[void 0]` is the first argument which represents `thisArg` to the bind method above. - // And `thisArg` will be set to the return value of the constructor when instantiated - // with the new operator — regardless of any value we set `thisArg` to. Thus, we set it - // to an undefined, `void 0`. + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). if (languageVersion === 1 /* ES5 */ && node.arguments && hasSpreadElement(node.arguments)) { @@ -27161,12 +27953,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164 /* ArrowFunction */) { - if (node.expression.kind === 161 /* TypeAssertionExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166 /* ArrowFunction */) { + if (node.expression.kind === 163 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == 161 /* TypeAssertionExpression */) { + while (operand.kind === 163 /* TypeAssertionExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -27177,14 +27969,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 168 /* PrefixUnaryExpression */ && - operand.kind !== 167 /* VoidExpression */ && - operand.kind !== 166 /* TypeOfExpression */ && - operand.kind !== 165 /* DeleteExpression */ && - operand.kind !== 169 /* PostfixUnaryExpression */ && - operand.kind !== 159 /* NewExpression */ && - !(operand.kind === 158 /* CallExpression */ && node.parent.kind === 159 /* NewExpression */) && - !(operand.kind === 163 /* FunctionExpression */ && node.parent.kind === 158 /* CallExpression */)) { + if (operand.kind !== 170 /* PrefixUnaryExpression */ && + operand.kind !== 169 /* VoidExpression */ && + operand.kind !== 168 /* TypeOfExpression */ && + operand.kind !== 167 /* DeleteExpression */ && + operand.kind !== 171 /* PostfixUnaryExpression */ && + operand.kind !== 161 /* NewExpression */ && + !(operand.kind === 160 /* CallExpression */ && node.parent.kind === 161 /* NewExpression */) && + !(operand.kind === 165 /* FunctionExpression */ && node.parent.kind === 160 /* CallExpression */)) { emit(operand); return; } @@ -27213,7 +28005,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 /* VariableDeclaration */ || node.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 /* VariableDeclaration */ || node.parent.kind === 155 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27243,7 +28035,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 168 /* PrefixUnaryExpression */) { + if (node.operand.kind === 170 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); @@ -27299,10 +28091,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228 /* SourceFile */) { + if (current.kind === 230 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 209 /* ModuleBlock */) { return false; } else { @@ -27312,8 +28104,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 183 /* ExpressionStatement */); + (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 185 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && @@ -27365,7 +28157,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180 /* Block */) { + if (node && node.kind === 182 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -27380,12 +28172,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 206 /* ModuleDeclaration */); + if (node.kind === 209 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 208 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207 /* ModuleBlock */) { + if (node.kind === 209 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -27394,7 +28186,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { write(" "); emit(node); } @@ -27406,7 +28198,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 166 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -27419,7 +28211,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 184 /* IfStatement */) { + if (node.elseStatement.kind === 186 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -27431,7 +28223,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { write(" "); } else { @@ -27506,7 +28298,7 @@ var ts; var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -27527,13 +28319,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 189 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 191 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -27543,7 +28335,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188 /* ForInStatement */) { + if (node.kind === 190 /* ForInStatement */) { write(" in "); } else { @@ -27628,7 +28420,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -27658,7 +28450,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 154 /* ArrayLiteralExpression */ || node.initializer.kind === 155 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 156 /* ArrayLiteralExpression */ || node.initializer.kind === 157 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, true, undefined); @@ -27669,7 +28461,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { emitLines(node.statement.statements); } else { @@ -27681,7 +28473,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -27726,7 +28518,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221 /* CaseClause */) { + if (node.kind === 223 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -27781,7 +28573,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206 /* ModuleDeclaration */); + } while (node && node.kind !== 208 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -27806,7 +28598,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(167 /* VoidExpression */); + var result = ts.createSynthesizedNode(169 /* VoidExpression */); result.expression = zero; return result; } @@ -27882,15 +28674,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 199 /* VariableDeclaration */) { + if (root.kind === 201 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130 /* Parameter */) { + else if (root.kind === 131 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170 /* BinaryExpression */) { + if (root.kind === 172 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -27901,8 +28693,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 /* VariableDeclaration */ || name.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 /* VariableDeclaration */ || name.parent.kind === 155 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -27937,14 +28728,14 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(170 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(172 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(173 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -27958,13 +28749,17 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65 /* Identifier */) { - return createElementAccessExpression(object, propName); + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158 /* CallExpression */); + var call = ts.createSynthesizedNode(160 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -27981,9 +28776,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var propName = (p.name); + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -27997,8 +28791,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -28008,14 +28802,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154 /* ArrayLiteralExpression */) { + else if (target.kind === 156 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -28029,14 +28823,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write(")"); } } @@ -28060,12 +28854,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176 /* OmittedExpression */) { + else if (element.kind !== 178 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -28092,7 +28886,6 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2 /* ES6 */) { // downlevel emit for non-initialized let bindings defined in loops @@ -28105,8 +28898,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 188 /* ForInStatement */ && - node.parent.parent.kind !== 189 /* ForOfStatement */) { + node.parent.parent.kind !== 190 /* ForInStatement */ && + node.parent.parent.kind !== 191 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -28124,7 +28917,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176 /* OmittedExpression */) { + if (node.kind === 178 /* OmittedExpression */) { return; } var name = node.name; @@ -28136,56 +28929,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 201 /* VariableDeclaration */ && node.parent.kind !== 155 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - // do not rename if - // - language version is ES6+ - // - node is synthesized - // - node is not identifier (can happen when tree is malformed) - // - node is definitely not name of variable declaration. - // it still can be part of parameter declaration, this check will be done next - if (languageVersion >= 2 /* ES6 */ || - ts.nodeIsSynthesized(node) || - node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288 /* BlockScoped */) === 0) || combinedFlags & 1 /* Export */) { - // do not rename exported or non-block scoped variables - return; - } - // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 200 /* VariableDeclarationList */); - if (list.parent.kind === 181 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 207 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 180 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 /* SourceFile */ - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 228 /* SourceFile */; + node.parent.kind === 230 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28236,12 +28988,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_20 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -28332,12 +29084,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 /* GetAccessor */ ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 /* GetAccessor */ ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 166 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -28348,11 +29100,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163 /* FunctionExpression */) { + if (node.kind === 165 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -28361,7 +29113,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -28384,10 +29136,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { emitTrailingComments(node); } } @@ -28438,7 +29190,7 @@ var ts; // in that case. write(" { }"); } - else if (node.body.kind === 180 /* Block */) { + else if (node.body.kind === 182 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -28469,10 +29221,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 161 /* TypeAssertionExpression */) { + while (current.kind === 163 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 157 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -28548,9 +29300,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183 /* ExpressionStatement */) { + if (statement && statement.kind === 185 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 158 /* CallExpression */) { + if (expr && expr.kind === 160 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 91 /* SuperKeyword */) { return statement; @@ -28582,7 +29334,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128 /* ComputedPropertyName */) { + else if (memberName.kind === 129 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -28594,7 +29346,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 134 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -28634,11 +29386,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179 /* SemicolonClassElement */) { + if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) { + else if (member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -28657,7 +29409,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) { + else if (member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -28707,22 +29459,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) && !member.body) { + if ((member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 /* MethodDeclaration */ || - member.kind === 137 /* GetAccessor */ || - member.kind === 138 /* SetAccessor */) { + else if (member.kind === 136 /* MethodDeclaration */ || + member.kind === 138 /* GetAccessor */ || + member.kind === 139 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 137 /* GetAccessor */) { + if (member.kind === 138 /* GetAccessor */) { write("get "); } - else if (member.kind === 138 /* SetAccessor */) { + else if (member.kind === 139 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -28733,7 +29485,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179 /* SemicolonClassElement */) { + else if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -28758,11 +29510,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && !member.body) { + if (member.kind === 137 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 133 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 134 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28870,7 +29622,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -28950,7 +29702,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -29034,7 +29786,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -29093,11 +29845,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -29189,7 +29941,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 135 /* MethodDeclaration */) { + if (member.kind === 136 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -29227,7 +29979,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29257,7 +30009,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29299,10 +30051,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: return true; } return false; @@ -29312,7 +30064,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: return true; } return false; @@ -29322,9 +30074,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 202 /* ClassDeclaration */: - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return true; } return false; @@ -29335,7 +30087,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -29348,7 +30100,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -29366,7 +30118,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -29466,7 +30218,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -29500,7 +30252,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -29536,7 +30288,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207 /* ModuleBlock */) { + if (node.body.kind === 209 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -29576,7 +30328,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -29594,16 +30346,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 212 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -29631,7 +30383,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -29657,7 +30409,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 211 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -29676,7 +30428,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 210 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 212 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -29840,8 +30592,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 /* FunctionDeclaration */ && - expression.kind !== 202 /* ClassDeclaration */) { + if (expression.kind !== 203 /* FunctionDeclaration */ && + expression.kind !== 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -29877,7 +30629,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -29887,13 +30639,13 @@ var ts; externalImports.push(node); } break; - case 209 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 220 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 211 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 222 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -29909,12 +30661,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -29935,13 +30687,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -29960,8 +30715,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 216 /* ExportDeclaration */ || - (importNode.kind === 210 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 218 /* ExportDeclaration */ || + (importNode.kind === 212 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -29994,7 +30749,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 218 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30026,7 +30781,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216 /* ExportDeclaration */) { + if (externalImport.kind !== 218 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -30110,12 +30865,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 /* Identifier */ + var name_22 = local.kind === 65 /* Identifier */ ? local : local.name; - if (name_25) { + if (name_22) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30126,7 +30881,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */ || local.kind === 205 /* EnumDeclaration */) { + if (local.kind === 204 /* ClassDeclaration */ || local.kind === 208 /* ModuleDeclaration */ || local.kind === 207 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -30160,21 +30915,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205 /* EnumDeclaration */) { + if (node.kind === 207 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30183,7 +30938,7 @@ var ts; } return; } - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30192,17 +30947,17 @@ var ts; } return; } - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65 /* Identifier */) { + var name_23 = node.name; + if (name_23.kind === 65 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -30226,7 +30981,7 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 230 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); @@ -30279,10 +31034,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); // return + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -30297,21 +31052,21 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!importNode.importClause) { // 'import "..."' case // module is imported only for side-effects, setter body will be empty break; } // fall-through - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 /* ImportDeclaration */ + var defaultName = importNode.kind === 212 /* ImportDeclaration */ ? importNode.importClause.name : importNode.name; if (defaultName) { @@ -30323,10 +31078,10 @@ var ts; emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 /* ImportDeclaration */ && + if (importNode.kind === 212 /* ImportDeclaration */ && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { // emit re-export for namespace // import * as n from 'foo' // export {n} @@ -30346,7 +31101,7 @@ var ts; } decreaseIndent(); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -30389,10 +31144,10 @@ var ts; // - imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 216 /* ExportDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 201 /* FunctionDeclaration */: + case 218 /* ExportDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 203 /* FunctionDeclaration */: continue; } writeLine(); @@ -30415,7 +31170,11 @@ var ts; ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -30495,8 +31254,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -30634,7 +31393,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -30645,7 +31404,7 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } @@ -30654,20 +31413,20 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 215 /* ExportAssignment */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 217 /* ExportAssignment */: return false; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -30676,9 +31435,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 180 /* Block */ && + if (node.kind !== 182 /* Block */ && node.parent && - node.parent.kind === 164 /* ArrowFunction */ && + node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -30686,19 +31445,18 @@ var ts; // Emit comments for everything else. return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { case 65 /* Identifier */: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130 /* Parameter */: + return emitIdentifier(node); + case 131 /* Parameter */: return emitParameter(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return emitMethod(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessor(node); case 93 /* ThisKeyword */: return emitThis(node); @@ -30718,131 +31476,131 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return emitTemplateExpression(node); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return emitTemplateSpan(node); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitQualifiedName(node); - case 151 /* ObjectBindingPattern */: + case 153 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 152 /* ArrayBindingPattern */: + case 154 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return emitBindingElement(node); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 226 /* ShorthandPropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 158 /* CallExpression */: + case 160 /* CallExpression */: return emitCallExpression(node); - case 159 /* NewExpression */: + case 161 /* NewExpression */: return emitNewExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return emit(node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return emitParenExpression(node); - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return emitDeleteExpression(node); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return emitVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return emitBinaryExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return emitConditionalExpression(node); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return emitYieldExpression(node); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return; - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return emitBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitVariableStatement(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: return write(";"); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return emitExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return emitIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return emitDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return emitWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return emitForStatement(node); - case 189 /* ForOfStatement */: - case 188 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 190 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return emitReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return emitWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return emitSwitchStatement(node); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return emitLabelledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return emitThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return emitTryStatement(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return emitCatchClause(node); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return emitClassExpression(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return emitClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMember(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return emitImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFileNode(node); } } @@ -30874,7 +31632,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -30889,7 +31647,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 230 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -31086,7 +31844,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -31119,16 +31877,21 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -31138,11 +31901,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -31153,6 +31917,18 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + // Initialize a checker so that all our files are bound. + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -31192,8 +31968,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -31233,16 +32008,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -31276,14 +32049,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -31298,18 +32074,18 @@ var ts; // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } // We haven't looked for this file, do so now and cache result - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -31317,16 +32093,18 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path - filesByName[canonicalAbsolutePath] = file; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -31336,7 +32114,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -31354,7 +32132,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */ || node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */ || node.kind === 218 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -31375,7 +32153,7 @@ var ts; } } } - else if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -31656,9 +32434,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, @@ -32033,7 +32816,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 164 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 166 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -32045,30 +32828,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 180 /* Block */: + case 182 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 185 /* DoStatement */ || - parent_7.kind === 188 /* ForInStatement */ || - parent_7.kind === 189 /* ForOfStatement */ || - parent_7.kind === 187 /* ForStatement */ || - parent_7.kind === 184 /* IfStatement */ || - parent_7.kind === 186 /* WhileStatement */ || - parent_7.kind === 193 /* WithStatement */ || - parent_7.kind === 224 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 187 /* DoStatement */ || + parent_8.kind === 190 /* ForInStatement */ || + parent_8.kind === 191 /* ForOfStatement */ || + parent_8.kind === 189 /* ForStatement */ || + parent_8.kind === 186 /* IfStatement */ || + parent_8.kind === 188 /* WhileStatement */ || + parent_8.kind === 195 /* WithStatement */ || + parent_8.kind === 226 /* CatchClause */) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 197 /* TryStatement */) { + if (parent_8.kind === 199 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_7; + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -32091,23 +32874,23 @@ var ts; break; } // Fallthrough. - case 207 /* ModuleBlock */: { + case 209 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 208 /* CaseBlock */: { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 210 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -32135,12 +32918,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_27 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_27); + for (var name_24 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_24); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_27); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); if (!matches) { continue; } @@ -32153,14 +32936,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_27); + matches = patternMatcher.getMatches(containers, name_24); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_27, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -32198,7 +32981,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 128 /* ComputedPropertyName */) { + else if (declaration.name.kind === 129 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -32219,7 +33002,7 @@ var ts; } return true; } - if (expression.kind === 156 /* PropertyAccessExpression */) { + if (expression.kind === 158 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -32232,7 +33015,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -32308,17 +33091,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 206 /* ModuleDeclaration */); + } while (current.kind === 208 /* ModuleDeclaration */); // fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -32329,21 +33112,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -32355,7 +33138,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -32364,21 +33147,21 @@ var ts; } } break; - case 153 /* BindingElement */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: childNodes.push(node); break; } @@ -32426,17 +33209,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -32447,12 +33230,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 201 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 203 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 180 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 182 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -32512,7 +33295,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -32520,36 +33303,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 139 /* CallSignature */: + case 140 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: var variableDeclarationNode; - var name_28; - if (node.kind === 153 /* BindingElement */) { - name_28 = node.name; + var name_25; + if (node.kind === 155 /* BindingElement */) { + name_25 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 199 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 201 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -32557,24 +33340,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_28 = node.name; + name_25 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); } - case 136 /* Constructor */: + case 137 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -32604,17 +33387,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: return createSourceFileItem(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return createClassItem(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return createEnumItem(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return createModuleItem(node); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -32626,7 +33409,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -32638,7 +33421,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 180 /* Block */) { + if (node.body && node.body.kind === 182 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -32659,7 +33442,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -32683,7 +33466,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -32692,13 +33475,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 206 /* ModuleDeclaration */) { + while (node.body.kind === 208 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 228 /* SourceFile */ + return node.kind === 230 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -33213,7 +33996,7 @@ var ts; var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { if (!isAllPunctuation(identifier, wordStart, i)) { @@ -33274,7 +34057,7 @@ var ts; // 3) HTMLDocument -> HTML, Document // // etc. - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); @@ -33493,7 +34276,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 158 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 160 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -33501,7 +34284,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 65 /* Identifier */ ? expression - : expression.kind === 156 /* PropertyAccessExpression */ + : expression.kind === 158 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -33534,7 +34317,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 158 /* CallExpression */ || node.parent.kind === 159 /* NewExpression */) { + if (node.parent.kind === 160 /* CallExpression */ || node.parent.kind === 161 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -33587,25 +34370,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 162 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 178 /* TemplateSpan */ && node.parent.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 180 /* TemplateSpan */ && node.parent.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -33723,7 +34506,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 172 /* TemplateExpression */) { + if (template.kind === 174 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -33732,7 +34515,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 228 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 230 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -33933,40 +34716,40 @@ var ts; return false; } switch (n.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 151 /* ObjectBindingPattern */: - case 146 /* TypeLiteral */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 208 /* CaseBlock */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 153 /* ObjectBindingPattern */: + case 148 /* TypeLiteral */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 210 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 159 /* NewExpression */: + case 161 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: - case 150 /* ParenthesizedType */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: + case 152 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -33976,63 +34759,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 184 /* IfStatement */: + case 186 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 154 /* ArrayLiteralExpression */: - case 152 /* ArrayBindingPattern */: - case 157 /* ElementAccessExpression */: - case 128 /* ComputedPropertyName */: - case 148 /* TupleType */: + case 156 /* ArrayLiteralExpression */: + case 154 /* ArrayBindingPattern */: + case 159 /* ElementAccessExpression */: + case 129 /* ComputedPropertyName */: + case 150 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 166 /* TypeOfExpression */: - case 165 /* DeleteExpression */: - case 167 /* VoidExpression */: - case 173 /* YieldExpression */: - case 174 /* SpreadElementExpression */: + case 168 /* TypeOfExpression */: + case 167 /* DeleteExpression */: + case 169 /* VoidExpression */: + case 175 /* YieldExpression */: + case 176 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -34088,7 +34871,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 251 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 253 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -34222,7 +35005,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 228 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 230 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -34266,17 +35049,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 142 /* TypeReference */ || node.kind === 158 /* CallExpression */) { + if (node.kind === 144 /* TypeReference */ || node.kind === 160 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 202 /* ClassDeclaration */ || node.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 204 /* ClassDeclaration */ || node.kind === 205 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 126 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 127 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -34331,7 +35114,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -34744,7 +35527,7 @@ var ts; if (this.tokensAreOnSameLine === undefined) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; }; @@ -34763,7 +35546,7 @@ var ts; FormattingContext.prototype.NodeIsOnOneLine = function (node) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); @@ -34923,7 +35706,7 @@ var ts; this.customContextChecks = funcs; } RuleOperationContext.prototype.IsAny = function () { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; }; RuleOperationContext.prototype.InContext = function (context) { if (this.IsAny()) { @@ -35029,7 +35812,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 121 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 122 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -35037,9 +35820,9 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 119 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118 /* ModuleKeyword */, 120 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 118 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 121 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 118 /* ModuleKeyword */, 119 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 122 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -35059,7 +35842,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 121 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 122 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110 /* YieldKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -35155,9 +35938,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_29 in o) { - if (o[name_29] === rule) { - return name_29; + for (var name_26 in o) { + if (o[name_26] === rule) { + return name_26; } } throw new Error("Unknown rule"); @@ -35166,36 +35949,37 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 187 /* ForStatement */; + return context.contextNode.kind === 189 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 143 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 153 /* BindingElement */: + case 155 /* BindingElement */: // equals in type X = ... - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: // equal in p = 0; - case 130 /* Parameter */: - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 131 /* Parameter */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 189 /* ForOfStatement */: - return context.currentTokenSpan.kind === 126 /* OfKeyword */ || context.nextTokenSpan.kind === 126 /* OfKeyword */; + case 191 /* ForOfStatement */: + return context.currentTokenSpan.kind === 127 /* OfKeyword */ || context.nextTokenSpan.kind === 127 /* OfKeyword */; } return false; }; @@ -35203,7 +35987,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 171 /* ConditionalExpression */; + return context.contextNode.kind === 173 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -35247,92 +36031,92 @@ var ts; return true; } switch (node.kind) { - case 180 /* Block */: - case 208 /* CaseBlock */: - case 155 /* ObjectLiteralExpression */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 210 /* CaseBlock */: + case 157 /* ObjectLiteralExpression */: + case 209 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 139 /* CallSignature */: - case 163 /* FunctionExpression */: - case 136 /* Constructor */: - case 164 /* ArrowFunction */: + case 140 /* CallSignature */: + case 165 /* FunctionExpression */: + case 137 /* Constructor */: + case 166 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 201 /* FunctionDeclaration */ || context.contextNode.kind === 163 /* FunctionExpression */; + return context.contextNode.kind === 203 /* FunctionDeclaration */ || context.contextNode.kind === 165 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 206 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 208 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 202 /* ClassDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 180 /* Block */: - case 224 /* CatchClause */: - case 207 /* ModuleBlock */: - case 194 /* SwitchStatement */: + case 204 /* ClassDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 182 /* Block */: + case 226 /* CatchClause */: + case 209 /* ModuleBlock */: + case 196 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 184 /* IfStatement */: - case 194 /* SwitchStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 197 /* TryStatement */: - case 185 /* DoStatement */: - case 193 /* WithStatement */: + case 186 /* IfStatement */: + case 196 /* SwitchStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 199 /* TryStatement */: + case 187 /* DoStatement */: + case 195 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 224 /* CatchClause */: + case 226 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 155 /* ObjectLiteralExpression */; + return context.contextNode.kind === 157 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 158 /* CallExpression */; + return context.contextNode.kind === 160 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 159 /* NewExpression */; + return context.contextNode.kind === 161 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -35356,38 +36140,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 131 /* Decorator */; + return node.kind === 132 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 200 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 202 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind != 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 206 /* ModuleDeclaration */; + return context.contextNode.kind === 208 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 146 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 148 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 142 /* TypeReference */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 144 /* TypeReference */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return true; default: return false; @@ -35398,10 +36182,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 167 /* VoidExpression */; + return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 169 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 173 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 175 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -35425,7 +36209,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 126 /* LastToken */ + 1; + this.mapRowLength = 127 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -35445,13 +36229,13 @@ var ts; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange != formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != formatting.Shared.TokenRange.Any; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); @@ -35518,7 +36302,7 @@ var ts; RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - ts.Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; this.rulesInsertionIndexBitmap = temp; @@ -35535,7 +36319,7 @@ var ts; }; RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { var position; - if (rule.Operation.Action == 1 /* Ignore */) { + if (rule.Operation.Action === 1 /* Ignore */) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; @@ -35610,7 +36394,7 @@ var ts; return [this.token]; }; TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue == this.token; + return tokenValue === this.token; }; return TokenSingleValueAccess; })(); @@ -35620,7 +36404,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 126 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 127 /* LastToken */; token++) { result.push(token); } return result; @@ -35662,9 +36446,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 126 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 127 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 126 /* OfKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 127 /* OfKeyword */, 117 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); @@ -35672,7 +36456,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 120 /* NumberKeyword */, 122 /* StringKeyword */, 113 /* BooleanKeyword */, 123 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 121 /* NumberKeyword */, 123 /* StringKeyword */, 113 /* BooleanKeyword */, 124 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -35711,6 +36495,7 @@ var ts; return this.rulesMap; }; RulesProvider.prototype.ensureUpToDate = function (options) { + // TODO: Should this be '==='? if (this.options == null || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); var rulesMap = formatting.RulesMap.create(activeRules); @@ -35875,17 +36660,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 180 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 228 /* SourceFile */: - case 180 /* Block */: - case 207 /* ModuleBlock */: + return body && body.kind === 182 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 230 /* SourceFile */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36058,9 +36843,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 228 /* SourceFile */ || - parent.kind === 221 /* CaseClause */ || - parent.kind === 222 /* DefaultClause */) { + parent.kind === 230 /* SourceFile */ || + parent.kind === 223 /* CaseClause */ || + parent.kind === 224 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -36096,19 +36881,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 202 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 203 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 201 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 205 /* EnumDeclaration */: return 205 /* EnumDeclaration */; - case 137 /* GetAccessor */: return 116 /* GetKeyword */; - case 138 /* SetAccessor */: return 121 /* SetKeyword */; - case 135 /* MethodDeclaration */: + case 204 /* ClassDeclaration */: return 69 /* ClassKeyword */; + case 205 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; + case 203 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; + case 207 /* EnumDeclaration */: return 207 /* EnumDeclaration */; + case 138 /* GetAccessor */: return 116 /* GetKeyword */; + case 139 /* SetAccessor */: return 122 /* SetKeyword */; + case 136 /* MethodDeclaration */: if (node.asteriskToken) { return 35 /* AsteriskToken */; } // fall-through - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: return node.name.kind; } } @@ -36241,7 +37026,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 131 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 132 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -36564,20 +37349,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 136 /* Constructor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 166 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -36585,8 +37370,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36594,7 +37379,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36693,7 +37478,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 170 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 172 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -36722,6 +37507,10 @@ var ts; if (actualIndentation !== -1 /* Unknown */) { return actualIndentation; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + options.IndentSize; + } previous = current; current = current.parent; } @@ -36764,6 +37553,10 @@ var ts; if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { @@ -36804,7 +37597,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 228 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 230 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -36837,7 +37630,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 184 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 186 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -36849,23 +37642,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return node.parent.properties; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return node.parent.elements; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: { + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -36876,8 +37669,8 @@ var ts; } break; } - case 159 /* NewExpression */: - case 158 /* CallExpression */: { + case 161 /* NewExpression */: + case 160 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -36901,6 +37694,44 @@ var ts; return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1 /* Unknown */; } } + function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { + // actual indentation should not be used when: + // - node is close parenthesis - this is the end of the expression + if (node.kind === 17 /* CloseParenToken */) { + return -1 /* Unknown */; + } + if (node.parent && (node.parent.kind === 160 /* CallExpression */ || + node.parent.kind === 161 /* NewExpression */) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1 /* Unknown */; + } + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + return -1 /* Unknown */; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); var node = list[index]; @@ -36956,28 +37787,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 154 /* ArrayLiteralExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 155 /* ObjectLiteralExpression */: - case 146 /* TypeLiteral */: - case 148 /* TupleType */: - case 208 /* CaseBlock */: - case 222 /* DefaultClause */: - case 221 /* CaseClause */: - case 162 /* ParenthesizedExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 181 /* VariableStatement */: - case 199 /* VariableDeclaration */: - case 215 /* ExportAssignment */: - case 192 /* ReturnStatement */: - case 171 /* ConditionalExpression */: - case 152 /* ArrayBindingPattern */: - case 151 /* ObjectBindingPattern */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 156 /* ArrayLiteralExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 157 /* ObjectLiteralExpression */: + case 148 /* TypeLiteral */: + case 150 /* TupleType */: + case 210 /* CaseBlock */: + case 224 /* DefaultClause */: + case 223 /* CaseClause */: + case 164 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 183 /* VariableStatement */: + case 201 /* VariableDeclaration */: + case 217 /* ExportAssignment */: + case 194 /* ReturnStatement */: + case 173 /* ConditionalExpression */: + case 154 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: return true; } return false; @@ -36987,22 +37818,22 @@ var ts; return true; } switch (parent) { - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - return child !== 180 /* Block */; + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + return child !== 182 /* Block */; default: return false; } @@ -37015,8 +37846,7 @@ var ts; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// @@ -37085,7 +37915,7 @@ var ts; return this.getEnd() - this.getStart(sourceFile); }; NodeObject.prototype.getFullWidth = function () { - return this.end - this.getFullStart(); + return this.end - this.pos; }; NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { return this.getStart(sourceFile) - this.pos; @@ -37107,7 +37937,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(251 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(253 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -37126,7 +37956,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 127 /* FirstNode */) { + if (this.kind >= 128 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -37171,7 +38001,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -37181,7 +38011,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -37234,7 +38064,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 130 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 131 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -37243,15 +38073,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 206 /* ModuleDeclaration */ && declaration.body.kind === 206 /* ModuleDeclaration */) { + if (declaration.kind === 208 /* ModuleDeclaration */ && declaration.body.kind === 208 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 206 /* ModuleDeclaration */ && declaration.parent.kind === 206 /* ModuleDeclaration */) { + while (declaration.kind === 208 /* ModuleDeclaration */ && declaration.parent.kind === 208 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -37590,9 +38420,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -37612,9 +38442,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -37634,60 +38464,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 146 /* TypeLiteral */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 148 /* TypeLiteral */: addDeclaration(node); // fall through - case 136 /* Constructor */: - case 181 /* VariableStatement */: - case 200 /* VariableDeclarationList */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 207 /* ModuleBlock */: + case 137 /* Constructor */: + case 183 /* VariableStatement */: + case 202 /* VariableDeclarationList */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 209 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 130 /* Parameter */: + case 131 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: addDeclaration(node); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37699,7 +38529,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -37900,16 +38730,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 163 /* FunctionExpression */) { + if (declaration.kind === 165 /* FunctionExpression */) { return true; } - if (declaration.kind !== 199 /* VariableDeclaration */ && declaration.kind !== 201 /* FunctionDeclaration */) { + if (declaration.kind !== 201 /* VariableDeclaration */ && declaration.kind !== 203 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_8.kind === 228 /* SourceFile */ || parent_8.kind === 207 /* ModuleBlock */) { + if (parent_9.kind === 230 /* SourceFile */ || parent_9.kind === 209 /* ModuleBlock */) { return false; } } @@ -37953,9 +38783,8 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = {}; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); for (var _i = 0; _i < rootFileNames.length; _i++) { @@ -37968,9 +38797,6 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.normalizeFileName = function (fileName) { - return this.getCanonicalFileName(ts.normalizeSlashes(fileName)); - }; HostCache.prototype.createEntry = function (fileName) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -37981,13 +38807,14 @@ var ts; scriptSnapshot: scriptSnapshot }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; }; HostCache.prototype.getEntry = function (fileName) { - return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); }; HostCache.prototype.contains = function (fileName) { - return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); }; HostCache.prototype.getOrCreateEntry = function (fileName) { if (this.contains(fileName)) { @@ -37996,12 +38823,10 @@ var ts; return this.createEntry(fileName); }; HostCache.prototype.getRootFileNames = function () { - var _this = this; var fileNames = []; - ts.forEachKey(this.fileNameToEntry, function (key) { - var entry = _this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); } }); return fileNames; @@ -38061,7 +38886,7 @@ var ts; * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics) { + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. @@ -38075,9 +38900,8 @@ var ts; // Parse var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - // Store syntactic diagnostics - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics); + if (moduleName) { + sourceFile.moduleName = moduleName; } var newLine = ts.getNewLineCharacter(options); // Output @@ -38096,9 +38920,8 @@ var ts; getNewLine: function () { return newLine; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics()); - } + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); @@ -38158,10 +38981,16 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createDocumentRegistry() { + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() } @@ -38169,7 +38998,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); } return bucket; } @@ -38178,7 +39007,7 @@ var ts; var entries = ts.lookUp(buckets, name); var sourceFiles = []; for (var i in entries) { - var entry = entries[i]; + var entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -38201,16 +39030,17 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -38233,11 +39063,11 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.remove(fileName); } } return { @@ -38300,7 +39130,7 @@ var ts; else { if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -38310,7 +39140,7 @@ var ts; } else if (token === 53 /* EqualsToken */) { token = scanner.scan(); - if (token === 119 /* RequireKeyword */) { + if (token === 120 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -38339,7 +39169,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -38355,7 +39185,7 @@ var ts; token = scanner.scan(); if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -38378,7 +39208,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -38390,7 +39220,7 @@ var ts; } else if (token === 35 /* AsteriskToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -38413,7 +39243,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 195 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 197 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -38422,12 +39252,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 /* Identifier */ && - (node.parent.kind === 191 /* BreakStatement */ || node.parent.kind === 190 /* ContinueStatement */) && + (node.parent.kind === 193 /* BreakStatement */ || node.parent.kind === 192 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 /* Identifier */ && - node.parent.kind === 195 /* LabeledStatement */ && + node.parent.kind === 197 /* LabeledStatement */ && node.parent.label === node; } /** @@ -38435,7 +39265,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 195 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 197 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -38446,25 +39276,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 206 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 208 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 /* Identifier */ && @@ -38473,22 +39303,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 225 /* PropertyAssignment */ || node.parent.kind === 226 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 227 /* PropertyAssignment */ || node.parent.kind === 228 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 206 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 208 /* ModuleDeclaration */: return node.parent.name === node; - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -38547,7 +39377,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 126 /* LastKeyword */; i++) { + for (var i = 66 /* FirstKeyword */; i <= 127 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -38562,17 +39392,17 @@ var ts; return undefined; } switch (node.kind) { - case 228 /* SourceFile */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: return node; } } @@ -38580,38 +39410,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 206 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 202 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 203 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 204 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 205 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 199 /* VariableDeclaration */: + case 208 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 204 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 205 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 206 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 207 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 201 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 201 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 137 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 138 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 138 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 139 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 141 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 140 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 139 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 136 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 129 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 227 /* EnumMember */: return ScriptElementKind.variableElement; - case 130 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 211 /* ImportClause */: - case 218 /* ExportSpecifier */: - case 212 /* NamespaceImport */: + case 142 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 141 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 140 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 137 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 130 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 229 /* EnumMember */: return ScriptElementKind.variableElement; + case 131 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 220 /* ExportSpecifier */: + case 214 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -38634,9 +39464,7 @@ var ts; host.log(message); } } - function getCanonicalFileName(fileName) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { fileName = ts.normalizeSlashes(fileName); var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); @@ -38827,44 +39655,44 @@ var ts; return false; } switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 102 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -38872,20 +39700,20 @@ var ts; return true; } break; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -38893,7 +39721,7 @@ var ts; return true; } break; - case 130 /* Parameter */: + case 131 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -38909,17 +39737,17 @@ var ts; return true; } break; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 131 /* Decorator */: + case 132 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -38964,7 +39792,7 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } /// Completion function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { @@ -39053,11 +39881,11 @@ var ts; // visible symbols in the scope, and the node is the current location. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 156 /* PropertyAccessExpression */) { + if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 158 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 127 /* QualifiedName */) { + else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 128 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -39084,7 +39912,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */) { + if (node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -39142,13 +39970,13 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 211 /* ImportClause */)) { + else if (ts.getAncestor(contextToken, 213 /* ImportClause */)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 210 /* ImportDeclaration */); + var importDeclaration = ts.getAncestor(contextToken, 212 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); var exports; if (importDeclaration.moduleSpecifier) { @@ -39227,7 +40055,7 @@ var ts; // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 213 /* NamedImports */; + return node.parent.kind === 215 /* NamedImports */; } } return false; @@ -39237,38 +40065,38 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 158 /* CallExpression */ // func( a, | - || containingNodeKind === 136 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 159 /* NewExpression */ // new C(a, | - || containingNodeKind === 154 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 170 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 143 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 160 /* CallExpression */ // func( a, | + || containingNodeKind === 137 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === 161 /* NewExpression */ // new C(a, | + || containingNodeKind === 156 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 172 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 145 /* FunctionType */; // var x: (s: string, list| case 16 /* OpenParenToken */: - return containingNodeKind === 158 /* CallExpression */ // func( | - || containingNodeKind === 136 /* Constructor */ // constructor( | - || containingNodeKind === 159 /* NewExpression */ // new C(a| - || containingNodeKind === 162 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 150 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + return containingNodeKind === 160 /* CallExpression */ // func( | + || containingNodeKind === 137 /* Constructor */ // constructor( | + || containingNodeKind === 161 /* NewExpression */ // new C(a| + || containingNodeKind === 164 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 152 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument case 18 /* OpenBracketToken */: - return containingNodeKind === 154 /* ArrayLiteralExpression */; // [ | - case 117 /* ModuleKeyword */: // module | - case 118 /* NamespaceKeyword */: + return containingNodeKind === 156 /* ArrayLiteralExpression */; // [ | + case 118 /* ModuleKeyword */: // module | + case 119 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 206 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 208 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 202 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 204 /* ClassDeclaration */; // class A{ | case 53 /* EqualsToken */: - return containingNodeKind === 199 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 170 /* BinaryExpression */; // x = a| + return containingNodeKind === 201 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 172 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 172 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 174 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 178 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 180 /* TemplateSpan */; // `aa ${10} dd ${| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 134 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -39303,12 +40131,12 @@ var ts; function getContainingObjectLiteralApplicableForCompletion(previousToken) { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var parent_9 = previousToken.parent; + var parent_10 = previousToken.parent; switch (previousToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_9 && parent_9.kind === 155 /* ObjectLiteralExpression */) { - return parent_9; + if (parent_10 && parent_10.kind === 157 /* ObjectLiteralExpression */) { + return parent_10; } break; } @@ -39317,16 +40145,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return true; } return false; @@ -39336,63 +40164,63 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 199 /* VariableDeclaration */ || - containingNodeKind === 200 /* VariableDeclarationList */ || - containingNodeKind === 181 /* VariableStatement */ || - containingNodeKind === 205 /* EnumDeclaration */ || + return containingNodeKind === 201 /* VariableDeclaration */ || + containingNodeKind === 202 /* VariableDeclarationList */ || + containingNodeKind === 183 /* VariableStatement */ || + containingNodeKind === 207 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* ArrayBindingPattern */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x, y| + containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 154 /* ArrayBindingPattern */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x, y| case 20 /* DotToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [.| case 51 /* ColonToken */: - return containingNodeKind === 153 /* BindingElement */; // var {x :html| + return containingNodeKind === 155 /* BindingElement */; // var {x :html| case 18 /* OpenBracketToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [x| case 16 /* OpenParenToken */: - return containingNodeKind === 224 /* CatchClause */ || + return containingNodeKind === 226 /* CatchClause */ || isFunction(containingNodeKind); case 14 /* OpenBraceToken */: - return containingNodeKind === 205 /* EnumDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 146 /* TypeLiteral */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x| + return containingNodeKind === 207 /* EnumDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 148 /* TypeLiteral */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x| case 22 /* SemicolonToken */: - return containingNodeKind === 132 /* PropertySignature */ && + return containingNodeKind === 133 /* PropertySignature */ && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 203 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 146 /* TypeLiteral */); // let x : { a; | + (previousToken.parent.parent.kind === 205 /* InterfaceDeclaration */ || + previousToken.parent.parent.kind === 148 /* TypeLiteral */); // let x : { a; | case 24 /* LessThanToken */: - return containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || + return containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || isFunction(containingNodeKind); case 109 /* StaticKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; + return containingNodeKind === 134 /* PropertyDeclaration */; case 21 /* DotDotDotToken */: - return containingNodeKind === 130 /* Parameter */ || - containingNodeKind === 136 /* Constructor */ || + return containingNodeKind === 131 /* Parameter */ || + containingNodeKind === 137 /* Constructor */ || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 152 /* ArrayBindingPattern */); // var [...z| + previousToken.parent.parent.kind === 154 /* ArrayBindingPattern */); // var [...z| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 130 /* Parameter */; + return containingNodeKind === 131 /* Parameter */; case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: case 103 /* InterfaceKeyword */: case 83 /* FunctionKeyword */: case 98 /* VarKeyword */: case 116 /* GetKeyword */: - case 121 /* SetKeyword */: + case 122 /* SetKeyword */: case 85 /* ImportKeyword */: case 104 /* LetKeyword */: case 70 /* ConstKeyword */: case 110 /* YieldKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -39424,7 +40252,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 213 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 215 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -39441,7 +40269,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 225 /* PropertyAssignment */ && m.kind !== 226 /* ShorthandPropertyAssignment */) { + if (m.kind !== 227 /* PropertyAssignment */ && m.kind !== 228 /* ShorthandPropertyAssignment */) { // Ignore omitted expressions for missing members in the object literal return; } @@ -39491,10 +40319,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_30 in nameTable) { - if (!allNames[name_30]) { - allNames[name_30] = name_30; - var displayName = getCompletionEntryDisplayName(name_30, target, true); + for (var name_27 in nameTable) { + if (!allNames[name_27]) { + allNames[name_27] = name_27; + var displayName = getCompletionEntryDisplayName(name_27, target, true); if (displayName) { var entry = { name: displayName, @@ -39693,7 +40521,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 156 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 158 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -39702,7 +40530,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 158 /* CallExpression */ || location.kind === 159 /* NewExpression */) { + if (location.kind === 160 /* CallExpression */ || location.kind === 161 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -39715,7 +40543,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 159 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 161 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -39767,24 +40595,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 136 /* Constructor */)) { + (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 137 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 136 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 137 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 136 /* Constructor */) { + if (functionDeclaration.kind === 137 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -39807,7 +40635,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(124 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(125 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -39827,9 +40655,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 206 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 208 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 118 /* NamespaceKeyword */ : 117 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 119 /* NamespaceKeyword */ : 118 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -39850,13 +40678,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 140 /* ConstructSignature */) { + if (signatureDeclaration.kind === 141 /* ConstructSignature */) { displayParts.push(ts.keywordPart(88 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 139 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 140 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -39865,7 +40693,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 227 /* EnumMember */) { + if (declaration.kind === 229 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -39881,13 +40709,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 209 /* ImportEqualsDeclaration */) { + if (declaration.kind === 211 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(119 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(120 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -40014,8 +40842,8 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position @@ -40073,7 +40901,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 204 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -40089,8 +40917,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 136 /* Constructor */) || - (!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 137 /* Constructor */) || + (!selectConstructors && (d.kind === 203 /* FunctionDeclaration */ || d.kind === 136 /* MethodDeclaration */ || d.kind === 135 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -40159,7 +40987,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 226 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 228 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -40193,7 +41021,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -40288,74 +41116,74 @@ var ts; switch (node.kind) { case 84 /* IfKeyword */: case 76 /* ElseKeyword */: - if (hasKind(node.parent, 184 /* IfStatement */)) { + if (hasKind(node.parent, 186 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 192 /* ReturnStatement */)) { + if (hasKind(node.parent, 194 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 196 /* ThrowStatement */)) { + if (hasKind(node.parent, 198 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 197 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96 /* TryKeyword */: case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 197 /* TryStatement */)) { + if (hasKind(parent(node), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 194 /* SwitchStatement */)) { + if (hasKind(node.parent, 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67 /* CaseKeyword */: case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 194 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66 /* BreakKeyword */: case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 191 /* BreakStatement */) || hasKind(node.parent, 190 /* ContinueStatement */)) { + if (hasKind(node.parent, 193 /* BreakStatement */) || hasKind(node.parent, 192 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82 /* ForKeyword */: - if (hasKind(node.parent, 187 /* ForStatement */) || - hasKind(node.parent, 188 /* ForInStatement */) || - hasKind(node.parent, 189 /* ForOfStatement */)) { + if (hasKind(node.parent, 189 /* ForStatement */) || + hasKind(node.parent, 190 /* ForInStatement */) || + hasKind(node.parent, 191 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100 /* WhileKeyword */: case 75 /* DoKeyword */: - if (hasKind(node.parent, 186 /* WhileStatement */) || hasKind(node.parent, 185 /* DoStatement */)) { + if (hasKind(node.parent, 188 /* WhileStatement */) || hasKind(node.parent, 187 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 136 /* Constructor */)) { + if (hasKind(node.parent, 137 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 116 /* GetKeyword */: - case 121 /* SetKeyword */: - if (hasKind(node.parent, 137 /* GetAccessor */) || hasKind(node.parent, 138 /* SetAccessor */)) { + case 122 /* SetKeyword */: + if (hasKind(node.parent, 138 /* GetAccessor */) || hasKind(node.parent, 139 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 181 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 183 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -40371,10 +41199,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 196 /* ThrowStatement */) { + if (node.kind === 198 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 197 /* TryStatement */) { + else if (node.kind === 199 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -40402,19 +41230,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_10 = child.parent; - if (ts.isFunctionBlock(parent_10) || parent_10.kind === 228 /* SourceFile */) { - return parent_10; + var parent_11 = child.parent; + if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230 /* SourceFile */) { + return parent_11; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_10.kind === 197 /* TryStatement */) { - var tryStatement = parent_10; + if (parent_11.kind === 199 /* TryStatement */) { + var tryStatement = parent_11; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_10; + child = parent_11; } return undefined; } @@ -40423,7 +41251,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 191 /* BreakStatement */ || node.kind === 190 /* ContinueStatement */) { + if (node.kind === 193 /* BreakStatement */ || node.kind === 192 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -40437,25 +41265,25 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 194 /* SwitchStatement */: - if (statement.kind === 190 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 196 /* SwitchStatement */: + if (statement.kind === 192 /* ContinueStatement */) { continue; } // Fall through. - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -40467,18 +41295,18 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 130 /* Parameter */ && hasKind(container, 136 /* Constructor */)))) { + if (!(container.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 131 /* Parameter */ && hasKind(container, 137 /* Constructor */)))) { return undefined; } } else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 202 /* ClassDeclaration */) { + if (container.kind !== 204 /* ClassDeclaration */) { return undefined; } } else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 207 /* ModuleBlock */ || container.kind === 228 /* SourceFile */)) { + if (!(container.kind === 209 /* ModuleBlock */ || container.kind === 230 /* SourceFile */)) { return undefined; } } @@ -40490,20 +41318,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 207 /* ModuleBlock */: - case 228 /* SourceFile */: + case 209 /* ModuleBlock */: + case 230 /* SourceFile */: nodes = container.statements; break; - case 136 /* Constructor */: + case 137 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -40551,13 +41379,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 139 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 121 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 122 /* SetKeyword */); }); } } } @@ -40575,7 +41403,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 185 /* DoStatement */) { + if (loopNode.kind === 187 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { @@ -40596,13 +41424,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -40656,7 +41484,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 180 /* Block */))) { + if (!(func && hasKind(func.body, 182 /* Block */))) { return undefined; } var keywords = []; @@ -40672,7 +41500,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 184 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 186 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -40685,7 +41513,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 184 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 186 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -40864,17 +41692,17 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 214 /* ImportSpecifier */ || location.parent.kind === 218 /* ExportSpecifier */) && + (location.parent.kind === 216 /* ImportSpecifier */ || location.parent.kind === 220 /* ExportSpecifier */) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 218 /* ExportSpecifier */; + return declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 220 /* ExportSpecifier */; }); } function getDeclaredName(symbol, location) { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40901,7 +41729,7 @@ var ts; return location.getText(); } // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40925,7 +41753,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 202 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 204 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -40951,7 +41779,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -41139,13 +41967,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -41177,27 +42005,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -41206,7 +42034,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 228 /* SourceFile */) { + if (searchSpaceNode.kind === 230 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -41237,27 +42065,27 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 228 /* SourceFile */: - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + case 230 /* SourceFile */: + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -41311,11 +42139,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 202 /* ClassDeclaration */) { + if (declaration.kind === 204 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 203 /* InterfaceDeclaration */) { + else if (declaration.kind === 205 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -41376,19 +42204,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_31 = node.text; + var name_28 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_31); + var unionProperty = contextualType.getProperty(name_28); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_31); + var symbol = t.getProperty(name_28); if (symbol) { result_4.push(symbol); } @@ -41397,7 +42225,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_31); + var symbol_1 = contextualType.getProperty(name_28); if (symbol_1) { return [symbol_1]; } @@ -41455,10 +42283,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 169 /* PostfixUnaryExpression */ || parent.kind === 168 /* PrefixUnaryExpression */) { + if (parent.kind === 171 /* PostfixUnaryExpression */ || parent.kind === 170 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 170 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 172 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; } @@ -41492,33 +42320,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 224 /* CatchClause */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 226 /* CatchClause */: return 1 /* Value */; - case 129 /* TypeParameter */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 146 /* TypeLiteral */: + case 130 /* TypeParameter */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 148 /* TypeLiteral */: return 2 /* Type */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -41528,15 +42356,15 @@ var ts; else { return 4 /* Namespace */; } - case 213 /* NamedImports */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 210 /* ImportDeclaration */: - case 215 /* ExportAssignment */: - case 216 /* ExportDeclaration */: + case 215 /* NamedImports */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 212 /* ImportDeclaration */: + case 217 /* ExportAssignment */: + case 218 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 228 /* SourceFile */: + case 230 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -41546,7 +42374,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 142 /* TypeReference */ || node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent.kind === 144 /* TypeReference */ || + (node.parent.kind === 179 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -41554,32 +42383,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 156 /* PropertyAccessExpression */) { + if (root.parent.kind === 158 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 158 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 223 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 179 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 225 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 202 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 203 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 204 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || + (decl.kind === 205 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 127 /* QualifiedName */) { - while (root.parent && root.parent.kind === 127 /* QualifiedName */) { + if (root.parent.kind === 128 /* QualifiedName */) { + while (root.parent && root.parent.kind === 128 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 142 /* TypeReference */ && !isLastClause; + return root.parent.kind === 144 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 127 /* QualifiedName */) { + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -41589,15 +42418,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 127 /* QualifiedName */ && + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 209 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 211 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent.kind === 217 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -41637,8 +42466,8 @@ var ts; return; } switch (node.kind) { - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 8 /* StringLiteral */: case 80 /* FalseKeyword */: case 95 /* TrueKeyword */: @@ -41661,7 +42490,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 206 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 208 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -41695,6 +42524,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; + var classifiableNames = program.getClassifiableNames(); processNode(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; function pushClassification(start, length, type) { @@ -41704,6 +42534,9 @@ var ts; } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); + if ((flags & 788448 /* Classifiable */) === 0 /* None */) { + return; + } if (flags & 32 /* Class */) { return 11 /* className */; } @@ -41736,19 +42569,26 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 208 /* ModuleDeclaration */ && + ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } } function processNode(node) { // Only walk into nodes that intersect the requested span. - if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 65 /* Identifier */ && node.getWidth() > 0) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + if (node.kind === 65 /* Identifier */ && !ts.nodeIsMissing(node)) { + var identifier = node; + // Only bother calling into the typechecker if this is an identifier that + // could possibly resolve to a type name. This makes classification run + // in a third of the time it would normally take. + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } } @@ -41795,6 +42635,8 @@ var ts; function getEncodedSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var spanStart = span.start; + var spanLength = span.length; // Make a scanner we can get trivia from. var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); @@ -41806,42 +42648,47 @@ var ts; result.push(length); result.push(type); } - function classifyLeadingTrivia(token) { - var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); - if (tokenStart === token.pos) { - return; - } - // token has trivia. Classify them appropriately. + function classifyLeadingTriviaAndGetTokenStart(token) { triviaScanner.setTextPos(token.pos); while (true) { var start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; // The moment we get something that isn't trivia, then stop processing. if (!ts.isTrivia(kind)) { - return; + return start; + } + // Don't bother with newlines/whitespace. + if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { + continue; } // Only bother with the trivia if it at least intersects the span of interest. - if (ts.textSpanIntersectsWith(span, start, width)) { - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + if (kind === 6 /* ConflictMarkerTrivia */) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + pushClassification(start, width, 1 /* comment */); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); - continue; - } - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 61 /* equals */); - classifyDisabledMergeCode(text, start, end); - } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + ts.Debug.assert(ch === 61 /* equals */); + classifyDisabledMergeCode(text, start, end); } } } @@ -41875,16 +42722,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -41942,11 +42789,16 @@ var ts; } } function classifyToken(token) { - classifyLeadingTrivia(token); - if (token.getWidth() > 0) { + if (ts.nodeIsMissing(token)) { + return; + } + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { var type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -41970,16 +42822,16 @@ var ts; if (token) { if (tokenKind === 53 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 199 /* VariableDeclaration */ || - token.parent.kind === 133 /* PropertyDeclaration */ || - token.parent.kind === 130 /* Parameter */) { + if (token.parent.kind === 201 /* VariableDeclaration */ || + token.parent.kind === 134 /* PropertyDeclaration */ || + token.parent.kind === 131 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 170 /* BinaryExpression */ || - token.parent.kind === 168 /* PrefixUnaryExpression */ || - token.parent.kind === 169 /* PostfixUnaryExpression */ || - token.parent.kind === 171 /* ConditionalExpression */) { + if (token.parent.kind === 172 /* BinaryExpression */ || + token.parent.kind === 170 /* PrefixUnaryExpression */ || + token.parent.kind === 171 /* PostfixUnaryExpression */ || + token.parent.kind === 173 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -42002,32 +42854,32 @@ var ts; else if (tokenKind === 65 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 130 /* Parameter */: + case 131 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -42042,10 +42894,10 @@ var ts; return; } // Ignore nodes that don't intersect the original span to classify. - if (ts.textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { var children = element.getChildren(sourceFile); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; if (ts.isToken(child)) { classifyToken(child); } @@ -42372,7 +43224,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 220 /* ExternalModuleReference */ || + node.parent.kind === 222 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -42385,7 +43237,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 157 /* ElementAccessExpression */ && + node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -42433,7 +43285,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 121 /* SetKeyword */ || + keyword2 === 122 /* SetKeyword */ || keyword2 === 114 /* ConstructorKeyword */ || keyword2 === 109 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -42592,10 +43444,10 @@ var ts; angleBracketStack--; } else if (token === 112 /* AnyKeyword */ || - token === 122 /* StringKeyword */ || - token === 120 /* NumberKeyword */ || + token === 123 /* StringKeyword */ || + token === 121 /* NumberKeyword */ || token === 113 /* BooleanKeyword */ || - token === 123 /* SymbolKeyword */) { + token === 124 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -42766,7 +43618,7 @@ var ts; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 126 /* LastKeyword */; + return token >= 66 /* FirstKeyword */ && token <= 127 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -42824,7 +43676,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 228 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 230 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -42894,125 +43746,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 187 /* ForStatement */) { + if (node.parent.kind === 189 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 170 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 172 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind == 164 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 199 /* VariableDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 201 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return spanInVariableDeclaration(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return spanInParameterDeclaration(node); - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: return spanInBlock(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInBlock(node.block); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 184 /* IfStatement */: + case 186 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInForStatement(node); - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 197 /* TryStatement */: + case 199 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: // span on complete node return textSpan(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -43042,11 +43894,11 @@ var ts; return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 225 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 227 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 161 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 163 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -43059,12 +43911,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 188 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 190 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -43118,7 +43970,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 202 /* ClassDeclaration */ && functionDeclaration.kind !== 136 /* Constructor */); + (functionDeclaration.parent.kind === 204 /* ClassDeclaration */ && functionDeclaration.kind !== 137 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -43141,18 +43993,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 186 /* WhileStatement */: - case 184 /* IfStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 186 /* IfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -43160,7 +44012,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -43180,13 +44032,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -43194,25 +44046,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 205 /* EnumDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -43226,7 +44078,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -43236,17 +44088,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - case 187 /* ForStatement */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + case 189 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -43257,19 +44109,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 225 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 227 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 161 /* TypeAssertionExpression */) { + if (node.parent.kind === 163 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -43320,6 +44172,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + // TODO: should this be '==='? if (encoded == null) { return null; } @@ -43331,12 +44184,18 @@ var ts; var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; } LanguageServiceShimHostAdapter.prototype.log = function (s) { - this.shimHost.log(s); + if (this.loggingEnabled) { + this.shimHost.log(s); + } }; LanguageServiceShimHostAdapter.prototype.trace = function (s) { - this.shimHost.trace(s); + if (this.tracingEnabled) { + this.shimHost.trace(s); + } }; LanguageServiceShimHostAdapter.prototype.error = function (s) { this.shimHost.error(s); @@ -43348,8 +44207,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; @@ -43415,13 +44278,13 @@ var ts; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, noPerfLogging) { - if (!noPerfLogging) { + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { logger.log(actionDescription); var start = Date.now(); } var result = action(); - if (!noPerfLogging) { + if (logPerformance) { var end = Date.now(); logger.log(actionDescription + " completed in " + (end - start) + " msec"); if (typeof (result) === "string") { @@ -43434,9 +44297,9 @@ var ts; } return result; } - function forwardJSONCall(logger, actionDescription, action, noPerfLogging) { + function forwardJSONCall(logger, actionDescription, action, logPerformance) { try { - var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); return JSON.stringify({ result: result }); } catch (err) { @@ -43478,10 +44341,11 @@ var ts; _super.call(this, factory); this.host = host; this.languageService = languageService; + this.logPerformance = false; this.logger = this.host; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; /// DISPOSE /** @@ -43788,12 +44652,12 @@ var ts; function ClassifierShimObject(factory, logger) { _super.call(this, factory); this.logger = logger; + this.logPerformance = false; this.classifier = ts.createClassifier(); } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, - /*noPerfLogging:*/ true); + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { @@ -43815,9 +44679,10 @@ var ts; _super.call(this, factory); this.logger = logger; this.host = host; + this.logPerformance = false; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { @@ -43874,7 +44739,6 @@ var ts; var TypeScriptServicesFactory = (function () { function TypeScriptServicesFactory() { this._shims = []; - this.documentRegistry = ts.createDocumentRegistry(); } /* * Returns script API version. @@ -43884,6 +44748,9 @@ var ts; }; TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + } var hostAdapter = new LanguageServiceShimHostAdapter(host); var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService); diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts new file mode 100644 index 00000000000..77892cb8f0c --- /dev/null +++ b/scripts/errorCheck.ts @@ -0,0 +1,87 @@ +declare var require: any; +let fs = require('fs'); +let async = require('async'); +let glob = require('glob'); + +fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { + if (err) { + throw err; + } + + let messages = JSON.parse(data); + let keys = Object.keys(messages); + console.log('Loaded ' + keys.length + ' errors'); + + for (let k of keys) { + messages[k]['seen'] = false; + } + + let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; + + let baseDir = 'tests/baselines/reference/'; + fs.readdir(baseDir, (err, files) => { + files = files.filter(f => f.indexOf('.errors.txt') > 0); + let tasks: Array<(callback: () => void) => void> = []; + files.forEach(f => tasks.push(done => { + fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { + if (err) throw err; + + let g: string[]; + while (g = errRegex.exec(baseline)) { + var errCode = +g[1]; + let msg = keys.filter(k => messages[k].code === errCode)[0]; + messages[msg]['seen'] = true; + } + + done(); + }); + })); + + async.parallelLimit(tasks, 25, done => { + console.log('== List of errors not present in baselines =='); + let count = 0; + for (let k of keys) { + if (messages[k]['seen'] !== true) { + console.log(k); + count++; + } + } + console.log(count + ' of ' + keys.length + ' errors are not in baselines'); + }); + }); +}); + +fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => { + let errorRegexp = /\s(\w+): \{ code/g; + let errorNames: string[] = []; + let errMatch: string[]; + while (errMatch = errorRegexp.exec(data)) { + errorNames.push(errMatch[1]); + } + + let allSrc: string = ''; + glob('./src/**/*.ts', {}, (err, files) => { + console.log('Reading ' + files.length + ' source files'); + for(let file of files) { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { + continue; + } + + let src = fs.readFileSync(file, 'utf-8'); + allSrc = allSrc + src; + } + + console.log('Consumed ' + allSrc.length + ' characters of source'); + + let count = 0; + console.log('== List of errors not used in source ==') + for(let errName of errorNames) { + if (allSrc.indexOf(errName) < 0) { + console.log(errName); + count++; + } + } + console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); + }); +}); + diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index eaad8593eee..e403ed994e5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -630,7 +630,7 @@ namespace ts { function getStrictModeIdentifierMessage(node: Node) { // Provide specialized messages to help the user understand why we think they're in // strict mode. - if (getAncestor(node, SyntaxKind.ClassDeclaration) || getAncestor(node, SyntaxKind.ClassExpression)) { + if (getContainingClass(node)) { return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; } @@ -688,7 +688,7 @@ namespace ts { function getStrictModeEvalOrArgumentsMessage(node: Node) { // Provide specialized messages to help the user understand why we think they're in // strict mode. - if (getAncestor(node, SyntaxKind.ClassDeclaration) || getAncestor(node, SyntaxKind.ClassExpression)) { + if (getContainingClass(node)) { return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; } @@ -1031,7 +1031,7 @@ namespace ts { // containing class. if (node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && - (node.parent.parent.kind === SyntaxKind.ClassDeclaration || node.parent.parent.kind === SyntaxKind.ClassExpression)) { + isClassLike(node.parent.parent)) { let classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 87b5ac44dce..ac0656f6c6b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -74,6 +74,9 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + + getJsxElementAttributesType, + getJsxIntrinsicTagNames }; let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); @@ -115,6 +118,9 @@ namespace ts { let globalRegExpType: ObjectType; let globalTemplateStringsArrayType: ObjectType; let globalESSymbolType: ObjectType; + let jsxElementType: ObjectType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ + let jsxIntrinsicElementsType: ObjectType; let globalIterableType: GenericType; let globalIteratorType: GenericType; let globalIterableIteratorType: GenericType; @@ -124,6 +130,7 @@ namespace ts { let getGlobalParameterDecoratorType: () => ObjectType; let getGlobalPropertyDecoratorType: () => ObjectType; let getGlobalMethodDecoratorType: () => ObjectType; + let getGlobalTypedPropertyDescriptorType: () => ObjectType; let getGlobalPromiseType: () => ObjectType; let tryGetGlobalPromiseType: () => ObjectType; let getGlobalPromiseLikeType: () => ObjectType; @@ -139,7 +146,7 @@ namespace ts { let emitParam = false; let emitAwaiter = false; let emitGenerator = false; - + let resolutionTargets: Object[] = []; let resolutionResults: boolean[] = []; @@ -147,6 +154,7 @@ namespace ts { let symbolLinks: SymbolLinks[] = []; let nodeLinks: NodeLinks[] = []; let potentialThisCollisions: Node[] = []; + let awaitedTypeStack: number[] = []; let diagnostics = createDiagnosticCollection(); @@ -169,6 +177,22 @@ namespace ts { } }; + const JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; + + let subtypeRelation: Map = {}; + let assignableRelation: Map = {}; + let identityRelation: Map = {}; + + initializeTypeChecker(); + + return checker; + function getEmitResolver(sourceFile?: SourceFile) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -367,21 +391,38 @@ namespace ts { case SyntaxKind.SourceFile: if (!isExternalModule(location)) break; case SyntaxKind.ModuleDeclaration: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.ModuleMember)) { - if (result.flags & meaning || !(result.flags & SymbolFlags.Alias && getDeclarationOfAliasSymbol(result).kind === SyntaxKind.ExportSpecifier)) { - break loop; - } - result = undefined; - } - else if (location.kind === SyntaxKind.SourceFile || + let moduleExports = getSymbolOfNode(location).exports; + if (location.kind === SyntaxKind.SourceFile || (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { - result = getSymbolOfNode(location).exports["default"]; + + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (hasProperty(moduleExports, name) && + moduleExports[name].flags === SymbolFlags.Alias && + getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { + break; + } + + result = moduleExports["default"]; let localSymbol = getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + + if (result = getSymbol(moduleExports, name, meaning & SymbolFlags.ModuleMember)) { + break loop; + } break; case SyntaxKind.EnumDeclaration: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) { @@ -396,8 +437,8 @@ namespace ts { // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === SyntaxKind.ClassDeclaration && !(location.flags & NodeFlags.Static)) { - let ctor = findConstructorDeclaration(location.parent); + if (isClassLike(location.parent) && !(location.flags & NodeFlags.Static)) { + let ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & SymbolFlags.Value)) { // Remember the property node, it will be used later to report appropriate error @@ -407,6 +448,7 @@ namespace ts { } break; case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { if (lastLocation && lastLocation.flags & NodeFlags.Static) { @@ -418,6 +460,13 @@ namespace ts { } break loop; } + if (location.kind === SyntaxKind.ClassExpression && meaning & SymbolFlags.Class) { + let className = (location).name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } break; // It is not legal to reference a class's own type parameters from a computed property name that @@ -430,7 +479,7 @@ namespace ts { // case SyntaxKind.ComputedPropertyName: grandparent = location.parent.parent; - if (grandparent.kind === SyntaxKind.ClassDeclaration || grandparent.kind === SyntaxKind.InterfaceDeclaration) { + if (isClassLike(grandparent) || grandparent.kind === SyntaxKind.InterfaceDeclaration) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & SymbolFlags.Type)) { error(errorLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -464,15 +513,6 @@ namespace ts { } } break; - case SyntaxKind.ClassExpression: - if (meaning & SymbolFlags.Class) { - let className = (location).name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; case SyntaxKind.Decorator: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. @@ -1019,7 +1059,7 @@ namespace ts { return false; } - function findConstructorDeclaration(node: ClassDeclaration): ConstructorDeclaration { + function findConstructorDeclaration(node: ClassLikeDeclaration): ConstructorDeclaration { let members = node.members; for (let member of members) { if (member.kind === SyntaxKind.Constructor && nodeIsPresent((member).body)) { @@ -1154,7 +1194,9 @@ namespace ts { // Check if symbol is any of the alias return forEachValue(symbols, symbolFromSymbolTable => { - if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & SymbolFlags.Alias + && symbolFromSymbolTable.name !== "export=" + && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { if (!useOnlyExternalAliasing || // We can use any type of alias to get the name // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) { @@ -1196,7 +1238,7 @@ namespace ts { } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -1406,20 +1448,30 @@ namespace ts { // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. let _displayBuilder: SymbolDisplayBuilder; function getSymbolDisplayBuilder(): SymbolDisplayBuilder { + + function getNameOfSymbol(symbol: Symbol): string { + if (symbol.declarations && symbol.declarations.length) { + let declaration = symbol.declarations[0]; + if (declaration.name) { + return declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case SyntaxKind.ClassExpression: + return "(Anonymous class)"; + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return "(Anonymous function)"; + } + } + return symbol.name; + } + /** * Writes only the name of the symbol out to the writer. Uses the original source text * for the name of the symbol if it is available to match how the user inputted the name. */ function appendSymbolNameOnly(symbol: Symbol, writer: SymbolWriter): void { - if (symbol.declarations && symbol.declarations.length > 0) { - let declaration = symbol.declarations[0]; - if (declaration.name) { - writer.writeSymbol(declarationNameToString(declaration.name), symbol); - return; - } - } - - writer.writeSymbol(symbol.name, symbol); + writer.writeSymbol(getNameOfSymbol(symbol), symbol); } /** @@ -1988,7 +2040,7 @@ namespace ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -2572,10 +2624,10 @@ namespace ts { if (!node) { return typeParameters; } - if (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.FunctionDeclaration || - node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.MethodDeclaration || - node.kind === SyntaxKind.ArrowFunction) { - let declarations = (node).typeParameters; + if (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || + node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression || + node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.ArrowFunction) { + let declarations = (node).typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); } @@ -2585,8 +2637,8 @@ namespace ts { // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] { - var kind = symbol.flags & SymbolFlags.Class ? SyntaxKind.ClassDeclaration : SyntaxKind.InterfaceDeclaration; - return appendOuterTypeParameters(undefined, getDeclarationOfKind(symbol, kind)); + var declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); + return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -2594,7 +2646,8 @@ namespace ts { function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): TypeParameter[] { let result: TypeParameter[]; for (let node of symbol.declarations) { - if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) { + if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.ClassDeclaration || + node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.TypeAliasDeclaration) { let declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -2610,56 +2663,127 @@ namespace ts { return concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isConstructorType(type: Type): boolean { + return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Construct).length > 0; + } + + function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments { + return getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + + function getConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { + let typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return filter(getSignaturesOfType(type, SignatureKind.Construct), + sig => (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount); + } + + function getInstantiatedConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { + let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + let typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); + signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments)); + } + return signatures; + } + + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // unknownType if an error occurred during resolution of the extends expression, + // nullType if the extends expression is the null value, or + // an object type with at least one construct signature. + function getBaseConstructorTypeOfClass(type: InterfaceType): ObjectType { + if (!type.resolvedBaseConstructorType) { + let baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + let baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & TypeFlags.ObjectType) { + // Resolving the members of a class requires us to resolve the base class of that class. + // We force resolution here such that we catch circularities now. + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; + } + function getBaseTypes(type: InterfaceType): ObjectType[] { - let typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & SymbolFlags.Class) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & SymbolFlags.Interface) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { Debug.fail("type must be class or interface"); } } - - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } - function resolveBaseTypesOfClass(type: InterfaceTypeWithBaseTypes): void { - type.baseTypes = []; - let declaration = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - let baseTypeNode = getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - let baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & TypeFlags.Class) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); - } - } - else { - error(baseTypeNode, Diagnostics.A_class_may_only_extend_another_class); - } - } + function resolveBaseTypesOfClass(type: InterfaceType): void { + type.resolvedBaseTypes = emptyArray; + let baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & TypeFlags.ObjectType)) { + return; } + let baseTypeNode = getBaseTypeNodeOfClass(type); + let baseType: Type; + if (baseContructorType.symbol && baseContructorType.symbol.flags & SymbolFlags.Class) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + let constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface))) { + error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, + typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); + return; + } + type.resolvedBaseTypes = [baseType]; } - function resolveBaseTypesOfInterface(type: InterfaceTypeWithBaseTypes): void { - type.baseTypes = []; + function resolveBaseTypesOfInterface(type: InterfaceType): void { + type.resolvedBaseTypes = []; for (let declaration of type.symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration && getInterfaceBaseTypeNodes(declaration)) { for (let node of getInterfaceBaseTypeNodes(declaration)) { let baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { if (getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); @@ -2877,20 +3001,26 @@ namespace ts { sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } - function getDefaultConstructSignatures(classType: InterfaceType): Signature[]{ - let baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - let baseType = baseTypes[0]; - let baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), SignatureKind.Construct); - return map(baseSignatures, baseSignature => { - let signature = baseType.flags & TypeFlags.Reference ? - getSignatureInstantiation(baseSignature, (baseType).typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + function getDefaultConstructSignatures(classType: InterfaceType): Signature[] { + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; + let baseConstructorType = getBaseConstructorTypeOfClass(classType); + let baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); + let baseTypeNode = getBaseTypeNodeOfClass(classType); + let typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); + let typeArgCount = typeArguments ? typeArguments.length : 0; + let result: Signature[] = []; + for (let baseSig of baseSignatures) { + let typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + let sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes: Type[]): SymbolTable { @@ -3002,10 +3132,10 @@ namespace ts { if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - let baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + let baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & TypeFlags.ObjectType) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -3419,7 +3549,6 @@ namespace ts { let syntaxKind = kind === IndexKind.Number ? SyntaxKind.NumberKeyword : SyntaxKind.StringKeyword; let indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - let len = indexSymbol.declarations.length; for (let decl of indexSymbol.declarations) { let node = decl; if (node.parameters.length === 1) { @@ -3533,7 +3662,7 @@ namespace ts { // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists - links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent == typeParameter.parent); + links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent === typeParameter.parent); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -3691,10 +3820,30 @@ namespace ts { return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity); } + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace: string, name: string): Type { + var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } + function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } + /** + * Creates a TypeReference for a generic `TypedPropertyDescriptor`. + */ + function createTypedPropertyDescriptorType(propertyType: Type): Type { + let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } + /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -4141,14 +4290,14 @@ namespace ts { return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type); } - function getTypeWithoutConstructors(type: Type): Type { + function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { let resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { let result = createObjectType(TypeFlags.Anonymous, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } @@ -4158,10 +4307,6 @@ namespace ts { // TYPE CHECKING - let subtypeRelation: Map = {}; - let assignableRelation: Map = {}; - let identityRelation: Map = {}; - function isTypeIdenticalTo(source: Type, target: Type): boolean { return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } @@ -4182,8 +4327,8 @@ namespace ts { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); } - function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage): boolean { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); + function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source: Signature, target: Signature): boolean { @@ -5438,6 +5583,7 @@ namespace ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.DeleteExpression: @@ -5466,6 +5612,12 @@ namespace ts { case SyntaxKind.ThrowStatement: case SyntaxKind.TryStatement: case SyntaxKind.CatchClause: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxExpression: return forEachChild(node, isAssignedIn); } return false; @@ -5700,6 +5852,7 @@ namespace ts { let signature = getResolvedSignature(expr); if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { if (!assumeTrue) { @@ -5833,9 +5986,9 @@ namespace ts { } function captureLexicalThis(node: Node, container: Node): void { - let classNode = container.parent && container.parent.kind === SyntaxKind.ClassDeclaration ? container.parent : undefined; getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis; if (container.kind === SyntaxKind.PropertyDeclaration || container.kind === SyntaxKind.Constructor) { + let classNode = container.parent; getNodeLinks(classNode).flags |= NodeCheckFlags.CaptureThis; } else { @@ -5888,9 +6041,8 @@ namespace ts { captureLexicalThis(node, container); } - let classNode = container.parent && container.parent.kind === SyntaxKind.ClassDeclaration ? container.parent : undefined; - if (classNode) { - let symbol = getSymbolOfNode(classNode); + if (isClassLike(container.parent)) { + let symbol = getSymbolOfNode(container.parent); return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); } return anyType; @@ -5907,16 +6059,14 @@ namespace ts { function checkSuperExpression(node: Node): Type { let isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; - let enclosingClass = getAncestor(node, SyntaxKind.ClassDeclaration); - let baseClass: Type; - if (enclosingClass && getClassExtendsHeritageClauseElement(enclosingClass)) { - let classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - let baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } + let classDeclaration = getContainingClass(node); + let classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + let baseClassType = classType && getBaseTypes(classType)[0]; - if (!baseClass) { - error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class); + if (!baseClassType) { + if (!classDeclaration || !getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } @@ -5944,7 +6094,7 @@ namespace ts { } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === SyntaxKind.ClassDeclaration) { + if (container && isClassLike(container.parent)) { if (container.flags & NodeFlags.Static) { canUseSuperExpression = container.kind === SyntaxKind.MethodDeclaration || @@ -5970,11 +6120,11 @@ namespace ts { if ((container.flags & NodeFlags.Static) || isCallExpression) { getNodeLinks(node).flags |= NodeCheckFlags.SuperStatic; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= NodeCheckFlags.SuperInstance; - returnType = baseClass; + returnType = baseClassType; } if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) { @@ -6256,6 +6406,26 @@ namespace ts { return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr: JsxExpression|JsxSpreadAttribute): Type { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === SyntaxKind.JsxAttribute) { + let attrib = expr.parent; + let attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + + if (expr.kind === SyntaxKind.JsxSpreadAttribute) { + return getJsxElementAttributesType(expr.parent); + } + + return undefined; + } + // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node: Expression): Type { @@ -6283,7 +6453,8 @@ namespace ts { case SyntaxKind.NewExpression: return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: - return getTypeFromTypeNode((parent).type); + case SyntaxKind.AsExpression: + return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node); case SyntaxKind.PropertyAssignment: @@ -6297,6 +6468,9 @@ namespace ts { return getContextualTypeForSubstitutionExpression(parent.parent, node); case SyntaxKind.ParenthesizedExpression: return getContextualType(parent); + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxSpreadAttribute: + return getContextualTypeForJsxExpression(parent); } return undefined; } @@ -6437,7 +6611,6 @@ namespace ts { let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); - if (restElementType) { elementTypes.push(restElementType); } @@ -6597,6 +6770,444 @@ namespace ts { } } + + function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + + function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean { + if (lhs.kind !== rhs.kind) { + return false; + } + + if (lhs.kind === SyntaxKind.Identifier) { + return (lhs).text === (rhs).text; + } + + return (lhs).right.text === (rhs).right.text && + tagNamesAreEquivalent((lhs).left, (rhs).left); + } + + function checkJsxElement(node: JsxElement) { + // Check that the closing tag matches + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNode(node.openingElement.tagName)); + } + + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + + // Check children + for(let child of node.children) { + switch (child.kind) { + case SyntaxKind.JsxExpression: + checkJsxExpression(child); + break; + case SyntaxKind.JsxElement: + checkJsxElement(child); + break; + case SyntaxKind.JsxSelfClosingElement: + checkJsxSelfClosingElement(child); + break; + default: + // No checks for JSX Text + Debug.assert(child.kind === SyntaxKind.JsxText); + } + } + + return jsxElementType || anyType; + } + + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ + function isUnhyphenatedJsxName(name: string) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf("-") < 0; + } + + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ + function isJsxIntrinsicIdentifier(tagName: Identifier|QualifiedName) { + if (tagName.kind === SyntaxKind.QualifiedName) { + return false; + } + else { + return isIntrinsicJsxName((tagName).text); + } + } + + function checkJsxAttribute(node: JsxAttribute, elementAttributesType: Type, nameTable: Map) { + let correspondingPropType: Type = undefined; + + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + // If there's no corresponding property with this name, error + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { + error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + + let exprType: Type; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + + nameTable[node.name.text] = true; + return exprType; + } + + function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { + let type = checkExpression(node.expression); + let props = getPropertiesOfType(type); + for(let prop of props) { + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[prop.name]) { + let targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + + nameTable[prop.name] = true; + } + } + return type; + } + + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node: JsxOpeningLikeElement): Symbol { + let flags: JsxFlags = JsxFlags.UnknownElement; + let links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + + function lookupIntrinsicTag(node: JsxOpeningLikeElement): Symbol { + let intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + let intrinsicProp = getPropertyOfType(intrinsicElementsType, (node.tagName).text); + if (intrinsicProp) { + links.jsxFlags |= JsxFlags.IntrinsicNamedElement; + return intrinsicProp; + } + + // Intrinsic string indexer case + let indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); + if (indexSignatureType) { + links.jsxFlags |= JsxFlags.IntrinsicIndexedElement; + return intrinsicElementsType.symbol; + } + + // Wasn't found + error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (node.tagName).text, 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + + function lookupClassTag(node: JsxOpeningLikeElement): Symbol { + let valueSymbol: Symbol; + + // Look up the value in the current scope + if (node.tagName.kind === SyntaxKind.Identifier) { + valueSymbol = getResolvedSymbol(node.tagName); + } + else { + valueSymbol = checkQualifiedName(node.tagName).symbol; + } + + if (valueSymbol !== unknownSymbol) { + links.jsxFlags |= JsxFlags.ClassElement; + } + + return valueSymbol || unknownSymbol; + } + } + + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ + function getJsxElementInstanceType(node: JsxOpeningLikeElement) { + if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) { + // There is no such thing as an instance type for a non-class element + return undefined; + } + + let classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + + let valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + + // Resolve the signatures, preferring constructors + let signatures = getSignaturesOfType(valueType, SignatureKind.Construct); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, SignatureKind.Call); + + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName)); + return undefined; + } + } + + // Check that the constructor/factory returns an object type + let returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); + if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + + // Issue an error if this return type isn't assignable to JSX.ElementClass + let elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + + return returnType; + } + + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means every + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined); + // JSX.ElementAttributesProperty [symbol] + let attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type); + // JSX.ElementAttributesProperty [type] + let attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + let attribProperties = attribPropType && getPropertiesOfType(attribPropType); + + if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (attribProperties.length === 0) { + return ""; + } + // Element Attributes has one property, so the element attributes type will be the type of the corresponding + // property of the class instance type + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + // More than one property on ElementAttributesProperty is an error + else { + error(attribsPropTypeSym.declarations[0], Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + // No interface exists, so the element attributes type will be an implicit any + return undefined; + } + } + + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ + function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { + let links = getNodeLinks(node); + if (!links.resolvedJsxType) { + let sym = getJsxElementTagSymbol(node); + + if (links.jsxFlags & JsxFlags.ClassElement) { + let elemInstanceType = getJsxElementInstanceType(node); + + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = anyType; + } + + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, IndexKind.String); + } + else { + // Resolution failed, so we don't know + return links.resolvedJsxType = anyType; + } + } + + return links.resolvedJsxType; + } + + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ + function getJsxAttributePropertySymbol(attrib: JsxAttribute): Symbol { + let attributesType = getJsxElementAttributesType(attrib.parent); + let prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + + let jsxElementClassType: Type = undefined; + function getJsxGlobalElementClassType(): Type { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames(): Symbol[] { + let intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + + function checkJsxPreconditions(errorNode: Node) { + // Preconditions for using JSX + if ((compilerOptions.jsx || JsxEmit.None) === JsxEmit.None) { + error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + + function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + + let targetAttributesType = getJsxElementAttributesType(node); + + if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { + if (node.tagName.kind === SyntaxKind.Identifier) { + checkIdentifier(node.tagName); + } + else { + checkQualifiedName(node.tagName); + } + } + + let nameTable: Map = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + let sawSpreadedAny = false; + for (let i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === SyntaxKind.JsxAttribute) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); + let spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { + let targetProperties = getPropertiesOfType(targetAttributesType); + for (let i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & SymbolFlags.Optional) && + nameTable[targetProperties[i].name] === undefined) { + + error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + + function checkJsxExpression(node: JsxExpression) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } + // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s: Symbol) { @@ -6615,7 +7226,7 @@ namespace ts { } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - let enclosingClassDeclaration = getAncestor(node, SyntaxKind.ClassDeclaration); + let enclosingClassDeclaration = getContainingClass(node); let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; let declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -6870,7 +7481,7 @@ namespace ts { if (node.kind === SyntaxKind.TaggedTemplateExpression) { checkExpression((node).template); } - else { + else if (node.kind !== SyntaxKind.Decorator) { forEach((node).arguments, argument => { checkExpression(argument); }); @@ -6939,7 +7550,8 @@ namespace ts { function getSpreadArgumentIndex(args: Expression[]): number { for (let i = 0; i < args.length; i++) { - if (args[i].kind === SyntaxKind.SpreadElementExpression) { + let arg = args[i]; + if (arg && arg.kind === SyntaxKind.SpreadElementExpression) { return i; } } @@ -6950,7 +7562,9 @@ namespace ts { let adjustedArgCount: number; // Apparent number of arguments we will have in this call let typeArguments: NodeArray; // Type arguments (undefined if none) let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments - + let isDecorator: boolean; + let spreadArgIndex = -1; + if (node.kind === SyntaxKind.TaggedTemplateExpression) { let tagExpression = node; @@ -6976,6 +7590,11 @@ namespace ts { callIsIncomplete = !!templateLiteral.isUnterminated; } } + else if (node.kind === SyntaxKind.Decorator) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); + } else { let callExpression = node; if (!callExpression.arguments) { @@ -6992,6 +7611,7 @@ namespace ts { callIsIncomplete = (callExpression).arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); } // If the user supplied type arguments, but the number of type arguments does not match @@ -7004,7 +7624,6 @@ namespace ts { // If spread arguments are present, check that they correspond to a rest parameter. If so, no // further checking is necessary. - let spreadArgIndex = getSpreadArgumentIndex(args); if (spreadArgIndex >= 0) { return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1; } @@ -7041,7 +7660,7 @@ namespace ts { return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void { + function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void { let typeParameters = signature.typeParameters; let inferenceMapper = createInferenceMapper(context); @@ -7069,20 +7688,23 @@ namespace ts { // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - for (let i = 0; i < args.length; i++) { - let arg = args[i]; - if (arg.kind !== SyntaxKind.OmittedExpression) { + let argCount = getEffectiveArgumentCount(node, args, signature); + for (let i = 0; i < argCount; i++) { + let arg = getEffectiveArgument(node, args, i); + // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. + if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) { let paramType = getTypeAtPosition(signature, i); - let argType: Type; - if (i === 0 && args[i].parent.kind === SyntaxKind.TaggedTemplateExpression) { - argType = globalTemplateStringsArrayType; - } - else { + let argType = getEffectiveArgumentType(node, i, arg); + + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards let mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); } + inferTypes(context, argType, paramType); } } @@ -7090,8 +7712,10 @@ namespace ts { // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) + // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. + // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { - for (let i = 0; i < args.length; i++) { + for (let i = 0; i < argCount; i++) { // No need to check for omitted args and template expressions, their exlusion value is always undefined if (excludeArgument[i] === false) { let arg = args[i]; @@ -7104,7 +7728,7 @@ namespace ts { getInferredTypes(context); } - function checkTypeArguments(signature: Signature, typeArguments: TypeNode[], typeArgumentResultTypes: Type[], reportErrors: boolean): boolean { + function checkTypeArguments(signature: Signature, typeArguments: TypeNode[], typeArgumentResultTypes: Type[], reportErrors: boolean, headMessage?: DiagnosticMessage): boolean { let typeParameters = signature.typeParameters; let typeArgumentsAreAssignable = true; for (let i = 0; i < typeParameters.length; i++) { @@ -7115,35 +7739,53 @@ namespace ts { if (typeArgumentsAreAssignable /* so far */) { let constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, - Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + let errorInfo: DiagnosticMessageChain; + let typeArgumentHeadMessage = Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + + typeArgumentsAreAssignable = checkTypeAssignableTo( + typeArgument, + constraint, + reportErrors ? typeArgNode : undefined, + typeArgumentHeadMessage, + errorInfo); } } } + return typeArgumentsAreAssignable; } function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map, excludeArgument: boolean[], reportErrors: boolean) { - for (let i = 0; i < args.length; i++) { - let arg = args[i]; - if (arg.kind !== SyntaxKind.OmittedExpression) { + let argCount = getEffectiveArgumentCount(node, args, signature); + for (let i = 0; i < argCount; i++) { + let arg = getEffectiveArgument(node, args, i); + // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. + if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) let paramType = getTypeAtPosition(signature, i); - // A tagged template expression provides a special first argument, and string literals get string literal types - // unless we're reporting errors - let argType = i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression - ? globalTemplateStringsArrayType - : arg.kind === SyntaxKind.StringLiteral && !reportErrors + let argType = getEffectiveArgumentType(node, i, arg); + + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { + argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } // Use argument expression as error location when reporting errors - if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, - Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { + let errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + let headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } } } + return true; } @@ -7152,20 +7794,27 @@ namespace ts { * * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution - * expressions, where the first element of the list is the template for error reporting purposes. + * expressions, where the first element of the list is `undefined`. + * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types + * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node: CallLikeExpression): Expression[] { let args: Expression[]; if (node.kind === SyntaxKind.TaggedTemplateExpression) { let template = (node).template; - args = [template]; - + args = [undefined]; if (template.kind === SyntaxKind.TemplateExpression) { forEach((template).templateSpans, span => { args.push(span.expression); }); } } + else if (node.kind === SyntaxKind.Decorator) { + // For a decorator, we return undefined as we will determine + // the number and types of arguments for a decorator using + // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. + return undefined; + } else { args = (node).arguments || emptyArray; } @@ -7173,35 +7822,285 @@ namespace ts { return args; } + /** - * In a 'super' call, type arguments are not provided within the CallExpression node itself. - * Instead, they must be fetched from the class declaration's base type node. - * - * If 'node' is a 'super' call (e.g. super(...), new super(...)), then we attempt to fetch - * the type arguments off the containing class's first heritage clause (if one exists). Note that if - * type arguments are supplied on the 'super' call, they are ignored (though this is syntactically incorrect). - * - * In all other cases, the call's explicit type arguments are returned. - */ - function getEffectiveTypeArguments(callExpression: CallExpression): TypeNode[] { - if (callExpression.expression.kind === SyntaxKind.SuperKeyword) { - let containingClass = getAncestor(callExpression, SyntaxKind.ClassDeclaration); - let baseClassTypeNode = containingClass && getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ + function getEffectiveArgumentCount(node: CallLikeExpression, args: Expression[], signature: Signature) { + if (node.kind === SyntaxKind.Decorator) { + switch (node.parent.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) + return 1; + + case SyntaxKind.PropertyDeclaration: + // A property declaration decorator will have two arguments (see + // `PropertyDecorator` in core.d.ts) + return 2; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + // A method or accessor declaration decorator will have two or three arguments (see + // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If the method decorator signature only accepts a target and a key, we will only + // type check those arguments. + return signature.parameters.length >= 3 ? 3 : 2; + + case SyntaxKind.Parameter: + // A parameter declaration decorator will have three arguments (see + // `ParameterDecorator` in core.d.ts) + + return 3; + } } else { - // Ordinary case - simple function invocation. - return callExpression.typeArguments; + return args.length; } } + + /** + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ + function getEffectiveDecoratorFirstArgumentType(node: Node): Type { + // The first argument to a decorator is its `target`. + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + // For a class decorator, the `target` is the type of the class (e.g. the + // "static" or "constructor" side of the class) + let classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + + case SyntaxKind.Parameter: + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. + node = node.parent; + if (node.kind === SyntaxKind.Constructor) { + let classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + + // fall-through + + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.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: + 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: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ + function getEffectiveDecoratorSecondArgumentType(node: Node) { + // The second argument to a decorator is its `propertyKey` + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + + case SyntaxKind.Parameter: + node = node.parent; + if (node.kind === SyntaxKind.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 SyntaxKind.PropertyDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.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 + // be either string or symbol. + let element = node; + switch (element.name.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.NumericLiteral: + case SyntaxKind.StringLiteral: + return getStringLiteralType(element.name); + + case SyntaxKind.ComputedPropertyName: + let nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) { + return nameType; + } + else { + return stringType; + } + + default: + Debug.fail("Unsupported property name."); + return unknownType; + } - function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[]): Signature { + + default: + 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. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ + function getEffectiveDecoratorThirdArgumentType(node: 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 SyntaxKind.ClassDeclaration: + Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + + case SyntaxKind.Parameter: + // The `parameterIndex` for a parameter decorator is always a number + return numberType; + + case SyntaxKind.PropertyDeclaration: + Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` + // for the type of the member. + let propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + + default: + Debug.fail("Unsupported decorator target."); + return unknownType; + } + } + + /** + * Returns the effective argument type for the provided argument to a decorator. + */ + function getEffectiveDecoratorArgumentType(node: Decorator, argIndex: number): Type { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + + Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + + /** + * Gets the effective argument type for an argument in a call expression. + */ + function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number, arg: Expression): Type { + // Decorators provide special arguments, a tagged template expression provides + // a special first argument, and string literals get string literal types + // unless we're reporting errors + if (node.kind === SyntaxKind.Decorator) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression) { + return globalTemplateStringsArrayType; + } + + // This is not a synthetic argument, so we return 'undefined' + // to signal that the caller needs to check the argument. + return undefined; + } + + /** + * Gets the effective argument expression for an argument in a call expression. + */ + function getEffectiveArgument(node: CallLikeExpression, args: Expression[], argIndex: number) { + // For a decorator or the first argument of a tagged template expression we return undefined. + if (node.kind === SyntaxKind.Decorator || + (argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression)) { + return undefined; + } + + return args[argIndex]; + } + + /** + * Gets the error node to use when reporting errors for an effective argument. + */ + function getEffectiveArgumentErrorNode(node: CallLikeExpression, argIndex: number, arg: Expression) { + if (node.kind === SyntaxKind.Decorator) { + // For a decorator, we use the expression of the decorator for error reporting. + return (node).expression; + } + else if (argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression) { + // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. + return (node).template; + } + else { + return arg; + } + } + + function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[], headMessage?: DiagnosticMessage): Signature { let isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; + let isDecorator = node.kind === SyntaxKind.Decorator; let typeArguments: TypeNode[]; - if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + if (!isTaggedTemplate && !isDecorator) { + typeArguments = (node).typeArguments; // We already perform checking on the type arguments on the class declaration itself. if ((node).expression.kind !== SyntaxKind.SuperKeyword) { @@ -7213,7 +8112,7 @@ namespace ts { // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - error(node, Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); } @@ -7230,13 +8129,20 @@ namespace ts { // // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. + // + // For a decorator, no arguments are susceptible to contextual typing due to the fact + // decorators are applied to a declaration by the emitter, and not to an expression. let excludeArgument: boolean[]; - for (let i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); + if (!isDecorator) { + // We do not need to call `getEffectiveArgumentCount` here as it only + // applies when calculating the number of arguments for a decorator. + for (let i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; } - excludeArgument[i] = true; } } @@ -7303,8 +8209,8 @@ namespace ts { checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, typeArguments, [], /*reportErrors*/ true) + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, (node).typeArguments, [], /*reportErrors*/ true, headMessage) } else { Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -7314,12 +8220,16 @@ namespace ts { let diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + + if (headMessage) { + diagnosticChainHead = chainDiagnosticMessages(diagnosticChainHead, headMessage); + } reportNoCommonSupertypeError(inferenceCandidates, (node).expression || (node).tag, diagnosticChainHead); } } else { - error(node, Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + reportError(Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } // No signature was applicable. We have already reported the errors for the invalid signature. @@ -7336,13 +8246,23 @@ namespace ts { } return resolveErrorCall(node); + + function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { + let errorInfo: DiagnosticMessageChain; + errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = chainDiagnosticMessages(errorInfo, headMessage); + } + + diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } function chooseOverload(candidates: Signature[], relation: Map) { for (let originalCandidate of candidates) { if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - + let candidate: Signature; let typeArgumentsAreValid: boolean; let inferenceContext = originalCandidate.typeParameters @@ -7358,7 +8278,7 @@ namespace ts { typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false) } else { - inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } @@ -7409,7 +8329,11 @@ namespace ts { if (node.expression.kind === SyntaxKind.SuperKeyword) { let superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, SignatureKind.Construct), candidatesOutArray); + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + let baseTypeNode = getClassExtendsHeritageClauseElement(getContainingClass(node)); + let baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -7538,6 +8462,55 @@ namespace ts { return resolveCall(node, callSignatures, candidatesOutArray); } + + /** + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ + function getDiagnosticHeadMessageForDecoratorResolution(node: Decorator) { + switch (node.parent.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + return Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + + case SyntaxKind.Parameter: + return Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + + case SyntaxKind.PropertyDeclaration: + return Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + + /** + * Resolves a decorator as if it were a call expression. + */ + function resolveDecorator(node: Decorator, candidatesOutArray: Signature[]): Signature { + let funcType = checkExpression(node.expression); + let apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + + let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + + let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + let errorInfo: DiagnosticMessageChain; + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } // candidatesOutArray is passed by signature help in the language service, and collectCandidates // must fill it up with the appropriate candidate signatures @@ -7559,6 +8532,9 @@ namespace ts { else if (node.kind === SyntaxKind.TaggedTemplateExpression) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } + else if (node.kind === SyntaxKind.Decorator) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } else { Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); } @@ -7595,7 +8571,7 @@ namespace ts { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node: TypeAssertion): Type { + function checkAssertion(node: AssertionExpression) { let exprType = checkExpression(node.expression); let targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -7824,7 +8800,6 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - // Grammar checking let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { @@ -7923,7 +8898,7 @@ namespace ts { } } - checkFunctionExpressionBodies(node.body); + checkFunctionAndClassExpressionBodies(node.body); } } } @@ -8020,12 +8995,12 @@ namespace ts { } function checkTypeOfExpression(node: TypeOfExpression): Type { - let operandType = checkExpression(node.expression); + checkExpression(node.expression); return stringType; } function checkVoidExpression(node: VoidExpression): Type { - let operandType = checkExpression(node.expression); + checkExpression(node.expression); return undefinedType; } @@ -8354,7 +9329,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -8382,8 +9357,8 @@ namespace ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { let offendingSymbolOperand = someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? node.left : - someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : - undefined; + someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : + undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); return false; @@ -8437,7 +9412,7 @@ namespace ts { if (isFunctionLike(parent) && current === (parent).body) { return false; } - else if (current.kind === SyntaxKind.ClassDeclaration || current.kind === SyntaxKind.ClassExpression) { + else if (isClassLike(current)) { return true; } @@ -8578,7 +9553,7 @@ namespace ts { // contextually typed function and arrow expressions in the initial phase. function checkExpression(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type { let type: Type; - if (node.kind == SyntaxKind.QualifiedName) { + if (node.kind === SyntaxKind.QualifiedName) { type = checkQualifiedName(node); } else { @@ -8644,8 +9619,6 @@ namespace ts { return checkCallExpression(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertionExpression: - return checkTypeAssertion(node); case SyntaxKind.ParenthesizedExpression: return checkExpression((node).expression, contextualMapper); case SyntaxKind.ClassExpression: @@ -8655,6 +9628,9 @@ namespace ts { return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + return checkAssertion(node); case SyntaxKind.DeleteExpression: return checkDeleteExpression(node); case SyntaxKind.VoidExpression: @@ -8675,6 +9651,14 @@ namespace ts { return undefinedType; case SyntaxKind.YieldExpression: return checkYieldExpression(node); + case SyntaxKind.JsxExpression: + return checkJsxExpression(node); + case SyntaxKind.JsxElement: + return checkJsxElement(node); + case SyntaxKind.JsxSelfClosingElement: + return checkJsxSelfClosingElement(node); + case SyntaxKind.JsxOpeningElement: + Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -9064,31 +10048,28 @@ namespace ts { checkDecorators(node); } - function checkTypeReferenceNode(node: TypeReferenceNode) { - return checkTypeReferenceOrExpressionWithTypeArguments(node); + function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]): boolean { + let result = true; + for (let i = 0; i < typeParameters.length; i++) { + let constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + let typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; } - function checkExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - - function checkTypeReferenceOrExpressionWithTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments) { - // Grammar checking + function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) { checkGrammarTypeArguments(node, node.typeArguments); - let type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved - let symbol = getNodeLinks(node).resolvedSymbol; - let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; - let len = node.typeArguments.length; - for (let i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - let constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (produceDiagnostics && constraint) { - let typeArgument = (type).typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + let symbol = getNodeLinks(node).resolvedSymbol; + let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -9538,8 +10519,6 @@ namespace ts { return getTypeAtPosition(signature, 0); } - let awaitedTypeStack: number[] = []; - /** * Gets the "awaited type" of a type. * @param type The type to await. @@ -9723,35 +10702,54 @@ namespace ts { /** Check a decorator */ function checkDecorator(node: Decorator): void { - let expression: Expression = node.expression; - let exprType = checkExpression(expression); - + let signature = getResolvedSignature(node); + let returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & TypeFlags.Any) { + return; + } + + let expectedReturnType: Type; + let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + let errorInfo: DiagnosticMessageChain; switch (node.parent.kind) { case SyntaxKind.ClassDeclaration: let classSymbol = getSymbolOfNode(node.parent); let classConstructorType = getTypeOfSymbol(classSymbol); - let classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); - checkTypeAssignableTo(exprType, classDecoratorType, node); + expectedReturnType = getUnionType([classConstructorType, voidType]); break; + case SyntaxKind.Parameter: + expectedReturnType = voidType; + errorInfo = chainDiagnosticMessages( + errorInfo, + Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + + break; + case SyntaxKind.PropertyDeclaration: - checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); + expectedReturnType = voidType; + errorInfo = chainDiagnosticMessages( + errorInfo, + Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: let methodType = getTypeOfNode(node.parent); - let methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); - checkTypeAssignableTo(exprType, methodDecoratorType, node); - break; - - case SyntaxKind.Parameter: - checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); + let descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); break; } + + checkTypeAssignableTo( + returnType, + expectedReturnType, + node, + headMessage, + errorInfo); } - + /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node: TypeNode) { // When we are emitting type metadata for decorators, we need to try to check the type @@ -9829,7 +10827,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // fall-through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -9936,7 +10934,7 @@ namespace ts { forEach(node.statements, checkSourceElement); if (isFunctionBlock(node) || node.kind === SyntaxKind.ModuleBlock) { - checkFunctionExpressionBodies(node); + checkFunctionAndClassExpressionBodies(node); } } @@ -10012,7 +11010,7 @@ namespace ts { } // bubble up and find containing type - let enclosingClass = getAncestor(node, SyntaxKind.ClassDeclaration); + let enclosingClass = getContainingClass(node); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || isInAmbientContext(enclosingClass)) { return; @@ -10298,7 +11296,7 @@ namespace ts { function checkForStatement(node: ForStatement) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == SyntaxKind.VariableDeclarationList) { + if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) { checkGrammarVariableDeclarationList(node.initializer); } } @@ -10429,7 +11427,7 @@ namespace ts { if (allowStringInput) { return checkElementTypeOfArrayOrString(inputType, errorNode); } - + if (isArrayLikeType(inputType)) { let indexType = getIndexTypeOfType(inputType, IndexKind.Number); if (indexType) { @@ -10841,8 +11839,8 @@ namespace ts { checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); }); - if (type.flags & TypeFlags.Class && type.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { - let classDeclaration = type.symbol.valueDeclaration; + if (type.flags & TypeFlags.Class && isClassLike(type.symbol.valueDeclaration)) { + let classDeclaration = type.symbol.valueDeclaration; for (let member of classDeclaration.members) { // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, @@ -10948,17 +11946,19 @@ namespace ts { } function checkClassExpression(node: ClassExpression): Type { - grammarErrorOnNode(node, Diagnostics.class_expressions_are_not_currently_supported); - forEach(node.members, checkSourceElement); - return unknownType; + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node: ClassDeclaration) { - // Grammar checking if (!node.name && !(node.flags & NodeFlags.Default)) { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } + checkClassLikeDeclaration(node); + forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node: ClassLikeDeclaration) { checkGrammarClassDeclarationHeritageClauses(node); checkDecorators(node); if (node.name) { @@ -10971,45 +11971,46 @@ namespace ts { let symbol = getSymbolOfNode(node); let type = getDeclaredTypeOfSymbol(symbol); let staticType = getTypeOfSymbol(symbol); + let baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } - emitExtends = emitExtends || !isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - let baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + let baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { let baseType = baseTypes[0]; - checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); - let staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, - Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, SymbolFlags.Value)) { - error(baseTypeNode, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + let staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + forEach(baseTypeNode.typeArguments, checkSourceElement); + for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } + checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, + Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + let constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (forEach(constructors, sig => getReturnTypeOfSignature(sig) !== baseType)) { + error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } - checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - // Check that base type can be evaluated as expression - checkExpression(baseTypeNode.expression); - } - let implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { forEach(implementedTypeNodes, typeRefNode => { if (!isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { let t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -11025,7 +12026,6 @@ namespace ts { }); } - forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); @@ -11209,8 +12209,7 @@ namespace ts { if (!isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); forEach(node.members, checkSourceElement); @@ -11526,7 +12525,7 @@ namespace ts { // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); + let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= NodeCheckFlags.LexicalModuleMergesWithClass; @@ -11784,7 +12783,7 @@ namespace ts { } function checkTypePredicate(node: TypePredicateNode) { - if(!isInLegalTypePredicatePosition(node)) { + if (!isInLegalTypePredicatePosition(node)) { error(node, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); } } @@ -11899,8 +12898,8 @@ namespace ts { } } - // Function expression bodies are checked after all statements in the enclosing body. This is to ensure - // constructs like the following are permitted: + // Function and class expression bodies are checked after all statements in the enclosing body. This is + // to ensure constructs like the following are permitted: // let foo = function () { // let s = foo(); // return "hello"; @@ -11908,17 +12907,20 @@ namespace ts { // Here, performing a full type check of the body of the function expression whilst in the process of // determining the type of foo would cause foo to be given type any because of the recursive reference. // Delaying the type check of the body ensures foo has been assigned a type. - function checkFunctionExpressionBodies(node: Node): void { + function checkFunctionAndClassExpressionBodies(node: Node): void { switch (node.kind) { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - forEach((node).parameters, checkFunctionExpressionBodies); + forEach((node).parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case SyntaxKind.ClassExpression: + forEach((node).members, checkSourceElement); + break; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - forEach(node.decorators, checkFunctionExpressionBodies); - forEach((node).parameters, checkFunctionExpressionBodies); + forEach(node.decorators, checkFunctionAndClassExpressionBodies); + forEach((node).parameters, checkFunctionAndClassExpressionBodies); if (isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } @@ -11927,10 +12929,10 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.FunctionDeclaration: - forEach((node).parameters, checkFunctionExpressionBodies); + forEach((node).parameters, checkFunctionAndClassExpressionBodies); break; case SyntaxKind.WithStatement: - checkFunctionExpressionBodies((node).expression); + checkFunctionAndClassExpressionBodies((node).expression); break; case SyntaxKind.Decorator: case SyntaxKind.Parameter: @@ -11950,6 +12952,7 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.TemplateSpan: case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: @@ -11989,7 +12992,13 @@ namespace ts { case SyntaxKind.EnumMember: case SyntaxKind.ExportAssignment: case SyntaxKind.SourceFile: - forEachChild(node, checkFunctionExpressionBodies); + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.JsxOpeningElement: + forEachChild(node, checkFunctionAndClassExpressionBodies); break; } } @@ -12021,7 +13030,7 @@ namespace ts { potentialThisCollisions.length = 0; forEach(node.statements, checkSourceElement); - checkFunctionExpressionBodies(node); + checkFunctionAndClassExpressionBodies(node); if (isExternalModule(node)) { checkExternalModuleExports(node); @@ -12122,6 +13131,11 @@ namespace ts { case SyntaxKind.EnumDeclaration: copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.EnumMember); break; + case SyntaxKind.ClassExpression: + if ((location).name) { + copySymbol(location.symbol, meaning); + } + // Fall through case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: if (!(memberFlags & NodeFlags.Static)) { @@ -12161,46 +13175,10 @@ namespace ts { } } } - - if (isInsideWithStatementBody(location)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return []; - } - - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case SyntaxKind.SourceFile: - if (!isExternalModule(location)) break; - case SyntaxKind.ModuleDeclaration: - copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.ModuleMember); - break; - case SyntaxKind.EnumDeclaration: - copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.EnumMember); - break; - case SyntaxKind.ClassDeclaration: - case SyntaxKind.InterfaceDeclaration: - if (!(memberFlags & NodeFlags.Static)) { - copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type); - } - break; - case SyntaxKind.FunctionExpression: - if ((location).name) { - copySymbol(location.symbol, meaning); - } - break; - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - return symbolsToArray(symbols); } function isTypeDeclarationName(name: Node): boolean { - return name.kind == SyntaxKind.Identifier && + return name.kind === SyntaxKind.Identifier && isTypeDeclaration(name.parent) && (name.parent).name === name; } @@ -12281,6 +13259,9 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === SyntaxKind.JsxOpeningElement) || (entityName.parent.kind === SyntaxKind.JsxSelfClosingElement)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (isExpression(entityName)) { if (nodeIsMissing(entityName)) { // Missing entity name. @@ -12315,6 +13296,13 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } + else if (entityName.parent.kind === SyntaxKind.JsxAttribute) { + return getJsxAttributePropertySymbol(entityName.parent); + } + + if (entityName.parent.kind === SyntaxKind.TypePredicate) { + return resolveEntityName(entityName, /*meaning*/ SymbolFlags.FunctionScopedVariable); + } // Do we want to return undefined here? return undefined; @@ -12358,7 +13346,6 @@ namespace ts { case SyntaxKind.StringLiteral: // External module name in an import declaration - let moduleName: Expression; if ((isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || ((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) && @@ -12366,10 +13353,10 @@ namespace ts { return resolveExternalModuleName(node, node); } - // Intentional fall-through + // fall through case SyntaxKind.NumericLiteral: // index access - if (node.parent.kind == SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { + if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { let objectType = checkExpression((node.parent).expression); if (objectType === unknownType) return undefined; let apparentType = getApparentType(objectType); @@ -12405,6 +13392,12 @@ namespace ts { return getTypeOfExpression(node); } + if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } + if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration let symbol = getSymbolOfNode(node); @@ -12427,6 +13420,10 @@ namespace ts { return symbol && getTypeOfSymbol(symbol); } + if (isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } + if (isInRightSideOfImportOrExportAssignment(node)) { let symbol = getSymbolInfo(node); let declaredType = symbol && getDeclaredTypeOfSymbol(symbol); @@ -12436,6 +13433,7 @@ namespace ts { return unknownType; } + function getTypeOfExpression(expr: Expression): Type { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; @@ -12443,6 +13441,17 @@ namespace ts { return checkExpression(expr); } + /** + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ + function getParentTypeOfClassElement(node: ClassElement) { + let classSymbol = getSymbolOfNode(node.parent); + return node.flags & NodeFlags.Static + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } + // Return the list of properties of the given type, augmented with properties from Function // if the type has call or construct signatures function getAugmentedPropertiesOfType(type: Type): Symbol[] { @@ -12766,7 +13775,7 @@ namespace ts { break; } } - + return "Object"; } @@ -12892,7 +13901,7 @@ namespace ts { let isVariableDeclarationOrBindingElement = n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n); - let symbol = + let symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -12920,7 +13929,7 @@ namespace ts { if (!signature) { return unknownType; } - + let instantiatedSignature = getSignatureInstantiation(signature, typeArguments); return getOrCreateTypeFromSignature(instantiatedSignature); } @@ -12979,10 +13988,12 @@ namespace ts { globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); + getGlobalTypedPropertyDescriptorType = memoize(() => getGlobalType("TypedPropertyDescriptor", /*arity*/ 1)); getGlobalPromiseType = memoize(() => getGlobalType("Promise", /*arity*/ 1)); tryGetGlobalPromiseType = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Type, /*diagnostic*/ undefined) && getGlobalPromiseType()); getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); @@ -13040,7 +14051,6 @@ namespace ts { } // GRAMMAR CHECKING - function checkGrammarDecorators(node: Node): boolean { if (!node.decorators) { return false; @@ -13425,7 +14435,7 @@ namespace ts { } } - function checkGrammarClassDeclarationHeritageClauses(node: ClassDeclaration) { + function checkGrammarClassDeclarationHeritageClauses(node: ClassLikeDeclaration) { let seenExtendsClause = false; let seenImplementsClause = false; @@ -13549,13 +14559,13 @@ namespace ts { let currentKind: number; if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { // Grammar checking for computedPropertName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if ( prop.kind === SyntaxKind.MethodDeclaration) { + else if (prop.kind === SyntaxKind.MethodDeclaration) { currentKind = Property; } else if (prop.kind === SyntaxKind.GetAccessor) { @@ -13591,6 +14601,29 @@ namespace ts { } } + function checkGrammarJsxElement(node: JsxOpeningElement|JsxSelfClosingElement) { + const seen: Map = {}; + for (let attr of node.attributes) { + if (attr.kind === SyntaxKind.JsxSpreadAttribute) { + continue; + } + + let jsxAttr = (attr); + let name = jsxAttr.name; + if (!hasProperty(seen, name.text)) { + seen[name.text] = true; + } + else { + return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + + let initializer = jsxAttr.initializer; + if (initializer && initializer.kind === SyntaxKind.JsxExpression && !(initializer).expression) { + return grammarErrorOnNode(jsxAttr.initializer, Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInStatement | ForOfStatement): boolean { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; @@ -13688,7 +14721,7 @@ namespace ts { } } - if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -13819,7 +14852,7 @@ namespace ts { } } - let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); + let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -13967,6 +15000,11 @@ namespace ts { } } + function isEvalOrArgumentsIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && + ((node).text === "eval" || (node).text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { if (node.typeParameters) { return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -13980,7 +15018,7 @@ namespace ts { } function checkGrammarProperty(node: PropertyDeclaration) { - if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (isClassLike(node.parent)) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; @@ -14089,9 +15127,5 @@ namespace ts { return true; } } - - initializeTypeChecker(); - - return checker; } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f2b7dcc91c1..df980d7fd7e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -38,6 +38,16 @@ namespace ts { name: "inlineSources", type: "boolean", }, + { + name: "jsx", + type: { + "preserve": JsxEmit.Preserve, + "react": JsxEmit.React + }, + paramType: Diagnostics.KIND, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean", @@ -110,6 +120,7 @@ namespace ts { { name: "out", type: "string", + isFilePath: true, description: Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: Diagnostics.FILE, }, @@ -405,18 +416,29 @@ namespace ts { } function getFileNames(): string[] { - var fileNames: string[] = []; + let fileNames: string[] = []; if (hasProperty(json, "files")) { if (json["files"] instanceof Array) { fileNames = map(json["files"], s => combinePaths(basePath, s)); } } else { - var exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); - for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; - if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { + let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; + let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + for (let i = 0; i < sysFiles.length; i++) { + let name = sysFiles[i]; + if (fileExtensionIs(name, ".d.ts")) { + let baseName = name.substr(0, name.length - ".d.ts".length); + if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { + fileNames.push(name); + } + } + else if (fileExtensionIs(name, ".ts")) { + if (!contains(sysFiles, name + "x")) { + fileNames.push(name) + } + } + else { fileNames.push(name); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 0c0414f3b12..7b35c5e0d65 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -572,7 +572,7 @@ namespace ts { export function getNormalizedPathComponents(path: string, currentDirectory: string) { path = normalizeSlashes(path); let rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { // If the path is not rooted it is relative to current directory path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); @@ -702,9 +702,9 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedExtensions = [".ts", ".d.ts"]; + export const supportedExtensions = [".tsx", ".ts", ".d.ts"]; - const extensionsToRemove = [".d.ts", ".ts", ".js"]; + const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { for (let ext of extensionsToRemove) { if (fileExtensionIs(path, ext)) { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index a2edc632de3..54d0d6ff854 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -40,7 +40,6 @@ namespace ts { function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit { let newLine = host.getNewLine(); let compilerOptions = host.getCompilerOptions(); - let languageVersion = compilerOptions.target || ScriptTarget.ES3; let write: (s: string) => void; let writeLine: () => void; @@ -709,7 +708,12 @@ namespace ts { function writeModuleDeclaration(node: ModuleDeclaration) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & NodeFlags.Namespace) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); while (node.body.kind !== SyntaxKind.ModuleBlock) { node = node.body; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index beb35eec9bf..61acf271bc5 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -20,15 +20,10 @@ namespace ts { An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, @@ -104,7 +99,6 @@ namespace ts { case_or_default_expected: { code: 1130, category: DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -121,9 +115,6 @@ namespace ts { Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -134,7 +125,6 @@ namespace ts { Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -150,7 +140,6 @@ namespace ts { Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, @@ -205,6 +194,12 @@ namespace ts { with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -213,7 +208,6 @@ namespace ts { Module_0_has_no_exported_member_1: { code: 2305, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -398,11 +392,26 @@ namespace ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: 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: 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: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 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: 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: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -539,12 +548,13 @@ namespace ts { File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, @@ -566,6 +576,7 @@ namespace ts { _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -585,5 +596,10 @@ namespace ts { decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 089ddb6a83e..465f66ab921 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -67,22 +67,6 @@ "category": "Error", "code": 1023 }, - "A class or interface declaration can only have one 'extends' clause.": { - "category": "Error", - "code": 1024 - }, - "An 'extends' clause must precede an 'implements' clause.": { - "category": "Error", - "code": 1025 - }, - "A class can only extend a single class.": { - "category": "Error", - "code": 1026 - }, - "A class declaration can only have one 'implements' clause.": { - "category": "Error", - "code": 1027 - }, "Accessibility modifier already seen.": { "category": "Error", "code": 1028 @@ -99,10 +83,6 @@ "category": "Error", "code": 1031 }, - "An interface declaration cannot have an 'implements' clause.": { - "category": "Error", - "code": 1032 - }, "'super' must be followed by an argument list or member access.": { "category": "Error", "code": 1034 @@ -403,10 +383,6 @@ "category": "Error", "code": 1132 }, - "Type reference expected.": { - "category": "Error", - "code": 1133 - }, "Variable declaration expected.": { "category": "Error", "code": 1134 @@ -471,18 +447,6 @@ "category": "Error", "code": 1150 }, - "'var', 'let' or 'const' expected.": { - "category": "Error", - "code": 1152 - }, - "'let' declarations are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1153 - }, - "'const' declarations are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1154 - }, "'const' declarations must be initialized": { "category": "Error", "code": 1155 @@ -523,10 +487,6 @@ "category": "Error", "code": 1166 }, - "Computed property names are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1167 - }, "A computed property name in a method overload must directly refer to a built-in symbol.": { "category": "Error", "code": 1168 @@ -587,10 +547,6 @@ "category": "Error", "code": 1182 }, - "Destructuring declarations are not allowed in ambient contexts.": { - "category": "Error", - "code": 1183 - }, "An implementation cannot be declared in ambient contexts.": { "category": "Error", "code": 1184 @@ -726,7 +682,7 @@ "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": { "category": "Error", "code": 1219 - }, + }, "Generators are only available when targeting ECMAScript 6 or higher.": { "category": "Error", "code": 1220 @@ -810,6 +766,31 @@ "code": 1311 }, + "The return type of a property decorator function must be either 'void' or 'any'.": { + "category": "Error", + "code": 1236 + }, + "The return type of a parameter decorator function must be either 'void' or 'any'.": { + "category": "Error", + "code": 1237 + }, + "Unable to resolve signature of class decorator when called as an expression.": { + "category": "Error", + "code": 1238 + }, + "Unable to resolve signature of parameter decorator when called as an expression.": { + "category": "Error", + "code": 1239 + }, + "Unable to resolve signature of property decorator when called as an expression.": { + "category": "Error", + "code": 1240 + }, + "Unable to resolve signature of method decorator when called as an expression.": { + "category": "Error", + "code": 1241 + }, + "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -842,10 +823,6 @@ "category": "Error", "code": 2307 }, - "A module cannot have more than one export assignment.": { - "category": "Error", - "code": 2308 - }, "An export assignment cannot be used in a module with other exported elements.": { "category": "Error", "code": 2309 @@ -1582,6 +1559,27 @@ "category": "Error", "code": 2505 }, + "'{0}' is referenced directly or indirectly in its own base expression.": { + "category": "Error", + "code": 2506 + }, + "Type '{0}' is not a constructor function type.": { + "category": "Error", + "code": 2507 + }, + "No base constructor has the specified number of type arguments.": { + "category": "Error", + "code": 2508 + }, + "Base constructor return type '{0}' is not a class or interface type.": { + "category": "Error", + "code": 2509 + }, + "Base constructors must all have the same return type.": { + "category": "Error", + "code": 2510 + }, + "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { "category": "Error", "code": 2520 @@ -1603,6 +1601,47 @@ "code": 2524 }, + "JSX element attributes type '{0}' must be an object type.": { + "category": "Error", + "code": 2600 + }, + "The return type of a JSX element constructor must return an object type.": { + "category": "Error", + "code": 2601 + }, + "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist.": { + "category": "Error", + "code": 2602 + }, + "Property '{0}' in type '{1}' is not assignable to type '{2}'": { + "category": "Error", + "code": 2603 + }, + "JSX element type '{0}' does not have any construct or call signatures.": { + "category": "Error", + "code": 2604 + }, + "JSX element type '{0}' is not a constructor function for JSX elements.": { + "category": "Error", + "code": 2605 + }, + "Property '{0}' of JSX spread attribute is not assignable to target property.": { + "category": "Error", + "code": 2606 + }, + "JSX element class does not support attributes because it does not have a '{0}' property": { + "category": "Error", + "code": 2607 + }, + "The global type 'JSX.{0}' may not have more than one property": { + "category": "Error", + "code": 2608 + }, + "Cannot emit namespaced JSX elements in React": { + "category": "Error", + "code": 2650 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -1971,7 +2010,7 @@ "category": "Error", "code": 5050 }, - "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { + "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, @@ -2148,10 +2187,6 @@ "category": "Message", "code": 6056 }, - "Preserve new-lines when emitting code.": { - "category": "Message", - "code": 6057 - }, "Specifies the root directory of input files. Use to control the output directory structure with --outDir.": { "category": "Message", "code": 6058 @@ -2164,14 +2199,22 @@ "category": "Message", "code": 6060 }, - "NEWLINE": { - "category": "Message", + "NEWLINE": { + "category": "Message", "code": 6061 }, "Argument for '--newLine' option must be 'CRLF' or 'LF'.": { - "category": "Error", + "category": "Error", "code": 6062 }, + "Specify JSX code generation: 'preserve' or 'react'": { + "category": "Message", + "code": 6080 + }, + "Argument for '--jsx' must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { "category": "Error", "code": 6064 @@ -2257,6 +2300,12 @@ "category": "Error", "code": 7025 }, + "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists": { + "category": "Error", + "code": 7026 + }, + + "You cannot rename this element.": { "category": "Error", "code": 8000 @@ -2333,5 +2382,25 @@ "'class' expressions are not currently supported.": { "category": "Error", "code": 9003 + }, + "JSX attributes must only be assigned a non-empty 'expression'.": { + "category": "Error", + "code": 17000 + }, + "JSX elements cannot have multiple attributes with the same name.": { + "category": "Error", + "code": 17001 + }, + "Expected corresponding JSX closing tag for '{0}'.": { + "category": "Error", + "code": 17002 + }, + "JSX attribute expected.": { + "category": "Error", + "code": 17003 + }, + "Cannot use JSX unless the '--jsx' flag is provided.": { + "category": "Error", + "code": 17004 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a5271b27c2c..9a05f145e6d 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -21,8 +21,7 @@ namespace ts { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); };`; // emit output for the __decorate helper function @@ -68,11 +67,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; let newLine = host.getNewLine(); + let jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve; + let shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring); if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -84,7 +85,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -281,6 +282,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return makeUniqueName("default"); } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node: Node) { switch (node.kind) { case SyntaxKind.Identifier: @@ -293,9 +298,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return generateNameForImportOrExportDeclaration(node); case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: case SyntaxKind.ExportAssignment: return generateNameForExportDefault(); + case SyntaxKind.ClassExpression: + return generateNameForClassExpression(); } } @@ -336,7 +342,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { // Emit comma to separate the entry if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; @@ -419,8 +425,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -670,7 +676,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind != SyntaxKind.SourceFile) { + if (node.kind !== SyntaxKind.SourceFile) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -1123,6 +1129,224 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(span.literal); } + function jsxEmitReact(node: JsxElement|JsxSelfClosingElement) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name: Identifier|QualifiedName) { + if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((name).text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name: Identifier) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node: JsxAttribute) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + + function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + write("React.createElement("); + emitTagName(openingNode.tagName); + write(", "); + + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + let attrs = openingNode.attributes; + if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { + write("React.__spread("); + + let haveOpenedObjectLiteral = false; + for (let i = 0; i < attrs.length; i++) { + if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { + // If this is the first argument, we need to emit a {} as the first argument + if (i === 0) { + write("{}, "); + } + + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i > 0) { + write(", "); + } + emit((attrs[i]).expression); + } + else { + Debug.assert(attrs[i].kind === SyntaxKind.JsxAttribute); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i]); + } + } + if (haveOpenedObjectLiteral) write("}"); + + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === SyntaxKind.JsxExpression && !((children[i]).expression)) { + continue; + } + + // Don't emit empty strings + if (children[i].kind === SyntaxKind.JsxText) { + let text = getTextToEmit(children[i]); + if(text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(", "); + emit(children[i]); + } + + } + } + + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + + if (node.kind === SyntaxKind.JsxElement) { + emitJsxElement((node).openingElement, (node).children); + } + else { + Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement); + emitJsxElement(node); + } + } + + function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { + function emitJsxAttribute(node: JsxAttribute) { + emit(node.name); + write("="); + emit(node.initializer); + } + + function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { + write("{..."); + emit(node.expression); + write("}"); + } + + function emitAttributes(attribs: NodeArray) { + for (let i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + + if (attribs[i].kind === SyntaxKind.JsxSpreadAttribute) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + Debug.assert(attribs[i].kind === SyntaxKind.JsxAttribute); + emitJsxAttribute(attribs[i]); + } + } + } + + function emitJsxOpeningOrSelfClosingElement(node: JsxOpeningElement|JsxSelfClosingElement) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === SyntaxKind.JsxSelfClosingElement)) { + write(" "); + } + + emitAttributes(node.attributes); + + if (node.kind === SyntaxKind.JsxSelfClosingElement) { + write("/>"); + } + else { + write(">"); + } + } + + function emitJsxClosingElement(node: JsxClosingElement) { + write(""); + } + + function emitJsxElement(node: JsxElement) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + + emitJsxClosingElement(node.closingElement); + } + + if (node.kind === SyntaxKind.JsxElement) { + emitJsxElement(node); + } + else { + Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. @@ -1199,6 +1423,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.IfStatement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: case SyntaxKind.NewExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PostfixUnaryExpression: @@ -1704,8 +1930,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function parenthesizeForAccess(expr: Expression): LeftHandSideExpression { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === SyntaxKind.TypeAssertionExpression) { - expr = (expr).expression; + while (expr.kind === SyntaxKind.TypeAssertionExpression || expr.kind === SyntaxKind.AsExpression) { + expr = (expr).expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -1824,7 +2050,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.expression); let indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - write("."); + + // 1 .toString is a valid property access, emit a space after the literal + let shouldEmitSpace: boolean; + if (!indentedBeforeDot && node.expression.kind === SyntaxKind.NumericLiteral) { + let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; + } + + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + let indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); @@ -1851,8 +2091,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function skipParentheses(node: Expression): Expression { - while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression) { - node = (node).expression; + while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression) { + node = (node).expression; } return node; } @@ -2002,12 +2242,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // not the user. If we didn't want them, the emitter would not have put them // there. if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) { - if (node.expression.kind === SyntaxKind.TypeAssertionExpression) { + if (node.expression.kind === SyntaxKind.TypeAssertionExpression || node.expression.kind === SyntaxKind.AsExpression) { let operand = (node.expression).expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == SyntaxKind.TypeAssertionExpression) { + while (operand.kind === SyntaxKind.TypeAssertionExpression || operand.kind === SyntaxKind.AsExpression) { operand = (operand).expression; } @@ -3181,33 +3421,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitDefaultValueAssignments(node: FunctionLikeDeclaration) { if (languageVersion < ScriptTarget.ES6) { let tempIndex = 0; - forEach(node.parameters, p => { + forEach(node.parameters, parameter => { // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. - if (p.dotDotDotToken) { + if (parameter.dotDotDotToken) { return; } - if (isBindingPattern(p.name)) { - writeLine(); - write("var "); - emitDestructuring(p, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); - write(";"); - tempIndex++; + let { name: paramName, initializer } = parameter; + if (isBindingPattern(paramName)) { + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + let hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + + if (hasBindingElements) { + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + + write(";"); + tempIndex++; + } } - else if (p.initializer) { + else if (initializer) { writeLine(); - emitStart(p); + emitStart(parameter); write("if ("); - emitNodeWithoutSourceMap(p.name); + emitNodeWithoutSourceMap(paramName); write(" === void 0)"); - emitEnd(p); + emitEnd(parameter); write(" { "); - emitStart(p); - emitNodeWithoutSourceMap(p.name); + emitStart(parameter); + emitNodeWithoutSourceMap(paramName); write(" = "); - emitNodeWithoutSourceMap(p.initializer); - emitEnd(p); + emitNodeWithoutSourceMap(initializer); + emitEnd(parameter); write("; }"); } }); @@ -3990,7 +4246,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitClassLikeDeclarationForES6AndHigher(node); } } - + function emitClassLikeDeclarationForES6AndHigher(node: ClassLikeDeclaration) { let thisNodeIsDecorated = nodeIsDecorated(node); if (node.kind === SyntaxKind.ClassDeclaration) { @@ -4249,7 +4505,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(".prototype"); } } - + function emitDecoratorsOfClass(node: ClassLikeDeclaration) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, NodeFlags.Static); @@ -5161,7 +5417,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let started = false; for (let importNode of externalImports) { // do not create variable declaration for exports and imports that lack import clause - let skipNode = + let skipNode = importNode.kind === SyntaxKind.ExportDeclaration || (importNode.kind === SyntaxKind.ImportDeclaration && !(importNode).importClause) @@ -5258,7 +5514,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("};"); return emitExportStarFunction(exportedNamesStorageRef); - + function emitExportStarFunction(localNames: string): string { const exportStarFunction = makeUniqueName("exportStar"); @@ -5285,7 +5541,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return exportStarFunction; } - + function writeExportedName(node: Identifier | Declaration): void { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export @@ -5530,7 +5786,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(/*newLine*/ true) + emitTempDeclarations(/*newLine*/ true); } function emitSetters(exportStarFunction: string) { @@ -5581,7 +5837,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (importNode.kind === SyntaxKind.ImportDeclaration && (importNode).importClause.namedBindings) { - + let namedBindings = (importNode).importClause.namedBindings; if (namedBindings.kind === SyntaxKind.NamespaceImport) { // emit re-export for namespace @@ -5840,6 +6096,99 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } + function emitJsxElement(node: JsxElement | JsxSelfClosingElement) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + jsxEmitReact(node); + break; + case JsxEmit.Preserve: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + + function trimReactWhitespace(node: JsxText): string { + let result: string = undefined; + let text = getTextOfNode(node); + let firstNonWhitespace = 0; + let lastNonWhitespace = -1; + + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (let i = 0; i < text.length; i++) { + let c = text.charCodeAt(i); + if (isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + '" + \' \' + "' : '') + part; + } + firstNonWhitespace = -1; + } + else if (!isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + let part = text.substr(firstNonWhitespace); + result = (result ? result + '" + \' \' + "' : '') + part; + } + + return result; + } + + function getTextToEmit(node: JsxText) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + let text = trimReactWhitespace(node); + if (text.length === 0) { + return undefined; + } + else { + return text; + } + case JsxEmit.Preserve: + default: + return getTextOfNode(node, true); + } + } + + function emitJsxText(node: JsxText) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + write('"'); + write(trimReactWhitespace(node)); + write('"'); + break; + + case JsxEmit.Preserve: + default: // Emit JSX-preserve as default when no --jsx flag is specified + write(getTextOfNode(node, true)); + break; + } + } + + function emitJsxExpression(node: JsxExpression) { + if (node.expression) { + switch (compilerOptions.jsx) { + case JsxEmit.Preserve: + default: + write('{'); + emit(node.expression); + write('}'); + break; + case JsxEmit.React: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements: Node[], startWithNewLine: boolean): number { for (let i = 0; i < statements.length; ++i) { if (isPrologueDirective(statements[i])) { @@ -5987,7 +6336,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.kind !== SyntaxKind.Block && node.parent && node.parent.kind === SyntaxKind.ArrowFunction && - (node.parent).body === node && + (node.parent).body === node && compilerOptions.target <= ScriptTarget.ES5) { return false; @@ -6032,6 +6381,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return emitTemplateExpression(node); case SyntaxKind.TemplateSpan: return emitTemplateSpan(node); + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + return emitJsxElement(node); + case SyntaxKind.JsxText: + return emitJsxText(node); + case SyntaxKind.JsxExpression: + return emitJsxExpression(node); case SyntaxKind.QualifiedName: return emitQualifiedName(node); case SyntaxKind.ObjectBindingPattern: @@ -6062,6 +6418,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return emitTaggedTemplateExpression(node); case SyntaxKind.TypeAssertionExpression: return emit((node).expression); + case SyntaxKind.AsExpression: + return emit((node).expression); case SyntaxKind.ParenthesizedExpression: return emitParenExpression(node); case SyntaxKind.FunctionDeclaration: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 98c9c56ae8c..c0118ec1984 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -164,6 +164,9 @@ namespace ts { return visitNode(cbNode, (node).left) || visitNode(cbNode, (node).operatorToken) || visitNode(cbNode, (node).right); + case SyntaxKind.AsExpression: + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).type); case SyntaxKind.ConditionalExpression: return visitNode(cbNode, (node).condition) || visitNode(cbNode, (node).questionToken) || @@ -321,6 +324,25 @@ namespace ts { return visitNode(cbNode, (node).expression); case SyntaxKind.MissingDeclaration: return visitNodes(cbNodes, node.decorators); + + case SyntaxKind.JsxElement: + return visitNode(cbNode, (node).openingElement) || + visitNodes(cbNodes, (node).children) || + visitNode(cbNode, (node).closingElement); + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: + return visitNode(cbNode, (node).tagName) || + visitNodes(cbNodes, (node).attributes); + case SyntaxKind.JsxAttribute: + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).initializer); + case SyntaxKind.JsxSpreadAttribute: + return visitNode(cbNode, (node).expression); + case SyntaxKind.JsxExpression: + return visitNode(cbNode, (node).expression); + case SyntaxKind.JsxClosingElement: + return visitNode(cbNode, (node).tagName); + case SyntaxKind.JSDocTypeExpression: return visitNode(cbNode, (node).type); case SyntaxKind.JSDocUnionType: @@ -524,6 +546,7 @@ namespace ts { scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(isTsx(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard); } function clearState() { @@ -636,6 +659,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0; + sourceFile.languageVariant = isTsx(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard; return sourceFile; } @@ -815,6 +839,10 @@ namespace ts { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier(): SyntaxKind { + return token = scanner.scanJsxIdentifier(); + } + function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -1179,6 +1207,10 @@ namespace ts { return isHeritageClause(); case ParsingContext.ImportOrExportSpecifiers: return isIdentifierOrKeyword(); + case ParsingContext.JsxAttributes: + return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken; + case ParsingContext.JsxChildren: + return true; case ParsingContext.JSDocFunctionParameters: case ParsingContext.JSDocTypeArguments: case ParsingContext.JSDocTupleTypes: @@ -1269,6 +1301,10 @@ namespace ts { return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.OpenParenToken; case ParsingContext.HeritageClauses: return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken; + case ParsingContext.JsxAttributes: + return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.SlashToken; + case ParsingContext.JsxChildren: + return token === SyntaxKind.LessThanToken && lookAhead(nextTokenIsSlash); case ParsingContext.JSDocFunctionParameters: return token === SyntaxKind.CloseParenToken || token === SyntaxKind.ColonToken || token === SyntaxKind.CloseBraceToken; case ParsingContext.JSDocTypeArguments: @@ -1485,6 +1521,12 @@ namespace ts { // name list, and there can be left hand side expressions (which can have type // arguments.) case ParsingContext.HeritageClauseElement: + + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case ParsingContext.JsxAttributes: + case ParsingContext.JsxChildren: + } return false; @@ -1495,12 +1537,20 @@ namespace ts { switch (node.kind) { case SyntaxKind.Constructor: case SyntaxKind.IndexSignature: - case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertyDeclaration: case SyntaxKind.SemicolonClassElement: return true; + case SyntaxKind.MethodDeclaration: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + let methodDeclaration = node; + let nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier && + (methodDeclaration.name).originalKeywordKind === SyntaxKind.ConstructorKeyword; + + return !nameIsConstructor; } } @@ -1643,6 +1693,8 @@ namespace ts { case ParsingContext.TupleElementTypes: return Diagnostics.Type_expected; case ParsingContext.HeritageClauses: return Diagnostics.Unexpected_token_expected; case ParsingContext.ImportOrExportSpecifiers: return Diagnostics.Identifier_expected; + case ParsingContext.JsxAttributes: return Diagnostics.Identifier_expected; + case ParsingContext.JsxChildren: return Diagnostics.Identifier_expected; case ParsingContext.JSDocFunctionParameters: return Diagnostics.Parameter_declaration_expected; case ParsingContext.JSDocTypeArguments: return Diagnostics.Type_argument_expected; case ParsingContext.JSDocTupleTypes: return Diagnostics.Type_expected; @@ -2803,6 +2855,33 @@ namespace ts { return Tristate.False; } + // JSX overrides + if (sourceFile.languageVariant === LanguageVariant.JSX) { + let isArrowFunctionInJsx = lookAhead(() => { + let third = nextToken(); + if (third === SyntaxKind.ExtendsKeyword) { + let fourth = nextToken(); + switch (fourth) { + case SyntaxKind.EqualsToken: + case SyntaxKind.GreaterThanToken: + return false; + default: + return true; + } + } + else if (third === SyntaxKind.CommaToken) { + return true; + } + return false; + }); + + if (isArrowFunctionInJsx) { + return Tristate.True; + } + + return Tristate.False; + } + // This *could* be a parenthesized arrow function. return Tristate.Unknown; } @@ -2924,7 +3003,23 @@ namespace ts { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === SyntaxKind.AsKeyword) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; @@ -2961,6 +3056,7 @@ namespace ts { case SyntaxKind.GreaterThanEqualsToken: case SyntaxKind.InstanceOfKeyword: case SyntaxKind.InKeyword: + case SyntaxKind.AsKeyword: return 7; case SyntaxKind.LessThanLessThanToken: case SyntaxKind.GreaterThanGreaterThanToken: @@ -2988,6 +3084,13 @@ namespace ts { return finishNode(node); } + function makeAsExpression(left: Expression, right: TypeNode): AsExpression { + let node = createNode(SyntaxKind.AsExpression, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { let node = createNode(SyntaxKind.PrefixUnaryExpression); node.operator = token; @@ -3057,7 +3160,13 @@ namespace ts { case SyntaxKind.VoidKeyword: return parseVoidExpression(); case SyntaxKind.LessThanToken: - return parseTypeAssertion(); + if (sourceFile.languageVariant !== LanguageVariant.JSX) { + return parseTypeAssertion(); + } + if(lookAhead(nextTokenIsIdentifier)) { + return parseJsxElementOrSelfClosingElement(); + } + // Fall through default: return parsePostfixExpressionOrHigher(); } @@ -3184,6 +3293,154 @@ namespace ts { node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } + + function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement { + let opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === SyntaxKind.JsxOpeningElement) { + let node = createNode(SyntaxKind.JsxElement, opening.pos); + node.openingElement = opening; + + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + Debug.assert(opening.kind === SyntaxKind.JsxSelfClosingElement); + // Nothing else to do for self-closing elements + return opening; + } + } + + function parseJsxText(): JsxText { + let node = createNode(SyntaxKind.JsxText, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + + function parseJsxChild(): JsxChild { + switch (token) { + case SyntaxKind.JsxText: + return parseJsxText(); + case SyntaxKind.OpenBraceToken: + return parseJsxExpression(); + case SyntaxKind.LessThanToken: + return parseJsxElementOrSelfClosingElement(); + } + Debug.fail('Unknown JSX child kind ' + token); + } + + function parseJsxChildren(openingTagName: EntityName): NodeArray { + let result = >[]; + result.pos = scanner.getStartPos(); + let saveParsingContext = parsingContext; + parsingContext |= 1 << ParsingContext.JsxChildren; + + while(true) { + token = scanner.reScanJsxToken(); + if (token === SyntaxKind.LessThanSlashToken) { + break; + } + else if (token === SyntaxKind.EndOfFileToken) { + parseErrorAtCurrentToken(Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + + result.end = scanner.getTokenPos(); + + parsingContext = saveParsingContext; + + return result; + } + + function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement { + let fullStart = scanner.getStartPos(); + + parseExpected(SyntaxKind.LessThanToken); + + let tagName = parseJsxElementName(); + + let attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); + let node: JsxOpeningLikeElement; + + if (parseOptional(SyntaxKind.GreaterThanToken)) { + node = createNode(SyntaxKind.JsxOpeningElement, fullStart); + } + else { + parseExpected(SyntaxKind.SlashToken); + parseExpected(SyntaxKind.GreaterThanToken); + node = createNode(SyntaxKind.JsxSelfClosingElement, fullStart); + } + + node.tagName = tagName; + node.attributes = attributes; + + return finishNode(node); + } + + function parseJsxElementName(): EntityName { + scanJsxIdentifier(); + let elementName: EntityName = parseIdentifier(); + while (parseOptional(SyntaxKind.DotToken)) { + scanJsxIdentifier(); + let node = createNode(SyntaxKind.QualifiedName, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + + function parseJsxExpression(): JsxExpression { + let node = createNode(SyntaxKind.JsxExpression); + + parseExpected(SyntaxKind.OpenBraceToken); + if (token !== SyntaxKind.CloseBraceToken) { + node.expression = parseExpression(); + } + parseExpected(SyntaxKind.CloseBraceToken); + + return finishNode(node); + } + + function parseJsxAttribute(): JsxAttribute | JsxSpreadAttribute { + if (token === SyntaxKind.OpenBraceToken) { + return parseJsxSpreadAttribute(); + } + + scanJsxIdentifier(); + let node = createNode(SyntaxKind.JsxAttribute); + node.name = parseIdentifierName(); + if (parseOptional(SyntaxKind.EqualsToken)) { + switch (token) { + case SyntaxKind.StringLiteral: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + + function parseJsxSpreadAttribute(): JsxSpreadAttribute { + let node = createNode(SyntaxKind.JsxSpreadAttribute); + parseExpected(SyntaxKind.OpenBraceToken); + parseExpected(SyntaxKind.DotDotDotToken); + node.expression = parseExpression(); + parseExpected(SyntaxKind.CloseBraceToken); + return finishNode(node); + } + + function parseJsxClosingElement(): JsxClosingElement { + let node = createNode(SyntaxKind.JsxClosingElement); + parseExpected(SyntaxKind.LessThanSlashToken); + node.tagName = parseJsxElementName(); + parseExpected(SyntaxKind.GreaterThanToken); + return finishNode(node); + } function parseTypeAssertion(): TypeAssertion { let node = createNode(SyntaxKind.TypeAssertionExpression); @@ -4060,7 +4317,7 @@ namespace ts { parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); @@ -4485,7 +4742,7 @@ namespace ts { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. let name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); @@ -4682,6 +4939,10 @@ namespace ts { return nextToken() === SyntaxKind.OpenParenToken; } + function nextTokenIsSlash() { + return nextToken() === SyntaxKind.SlashToken; + } + function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === SyntaxKind.CommaToken || @@ -4882,7 +5143,7 @@ namespace ts { } function processReferenceComments(sourceFile: SourceFile): void { - let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText); + let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText); let referencedFiles: FileReference[] = []; let amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; @@ -4969,6 +5230,8 @@ namespace ts { ArrayBindingElements, // Binding elements in array binding list ArgumentExpressions, // Expressions in argument list ObjectLiteralMembers, // Members in object literal + JsxAttributes, // Attributes in jsx element + JsxChildren, // Things between opening and closing JSX tags ArrayLiteralMembers, // Members in array literal Parameters, // Parameters in parameter list TypeParameters, // Type parameters in type parameter list @@ -5443,7 +5706,6 @@ namespace ts { let atToken = createNode(SyntaxKind.AtToken, pos - 1); atToken.end = pos; - let startPos = pos; let tagName = scanIdentifier(); if (!tagName) { return; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4484addd84e..b9321ab3461 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -105,7 +105,10 @@ namespace ts { } export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[] { - let diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + let diagnostics = program.getOptionsDiagnostics().concat( + program.getSyntacticDiagnostics(sourceFile), + program.getGlobalDiagnostics(), + program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); @@ -177,10 +180,10 @@ namespace ts { getSourceFiles: () => files, getCompilerOptions: () => options, getSyntacticDiagnostics, + getOptionsDiagnostics, getGlobalDiagnostics, getSemanticDiagnostics, getDeclarationDiagnostics, - getCompilerOptionsDiagnostics, getTypeChecker, getClassifiableNames, getDiagnosticsProducingTypeChecker, @@ -311,19 +314,15 @@ namespace ts { } } - function getCompilerOptionsDiagnostics(): Diagnostic[] { + function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics(): Diagnostic[] { - let typeChecker = getDiagnosticsProducingTypeChecker(); - let allDiagnostics: Diagnostic[] = []; - addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); - + addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -338,7 +337,6 @@ namespace ts { function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) { let start: number; let length: number; - let extensions: string; let diagnosticArgument: string[]; if (refEnd !== undefined && refPos !== undefined) { start = refPos; @@ -683,4 +681,4 @@ namespace ts { } } } -} \ No newline at end of file +} diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 67d67ba5071..bec5dcc284c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -21,12 +21,16 @@ namespace ts { reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; scan(): SyntaxKind; // Sets the text for the scanner to scan. An optional subrange starting point and length // can be provided to have the scanner only scan a portion of the text. setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; // Invokes the provided callback then unconditionally restores the scanner to the state it // was in immediately prior to invoking the callback. The result of invoking the callback @@ -132,6 +136,7 @@ namespace ts { "++": SyntaxKind.PlusPlusToken, "--": SyntaxKind.MinusMinusToken, "<<": SyntaxKind.LessThanLessThanToken, + ">": SyntaxKind.GreaterThanGreaterThanToken, ">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken, "&": SyntaxKind.AmpersandToken, @@ -378,8 +383,31 @@ namespace ts { return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; } + export function couldStartTrivia(text: string, pos: number): boolean { + // Keep in sync with skipTrivia + let ch = text.charCodeAt(pos); + switch (ch) { + case CharacterCodes.carriageReturn: + case CharacterCodes.lineFeed: + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + case CharacterCodes.slash: + // starts of normal trivia + case CharacterCodes.lessThan: + case CharacterCodes.equals: + case CharacterCodes.greaterThan: + // Starts of conflict marker trivia + return true; + default: + return ch > CharacterCodes.maxAsciiCharacter; + } + } + /* @internal */ export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number { + // Keep in sync with couldStartTrivia while (true) { let ch = text.charCodeAt(pos); switch (ch) { @@ -600,11 +628,12 @@ namespace ts { ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - + /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, + languageVariant = LanguageVariant.Standard, text?: string, onError?: ErrorCallback, start?: number, @@ -644,9 +673,13 @@ namespace ts { reScanGreaterToken, reScanSlashToken, reScanTemplateToken, + scanJsxIdentifier, + reScanJsxToken, + scanJsxToken, scan, setText, setScriptTarget, + setLanguageVariant, setOnError, setTextPos, tryScan, @@ -936,7 +969,7 @@ namespace ts { error(Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == CharacterCodes.closeBrace) { + else if (text.charCodeAt(pos) === CharacterCodes.closeBrace) { // Only swallow the following character up if it's a '}'. pos++; } @@ -1281,6 +1314,9 @@ namespace ts { if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.LessThanEqualsToken; } + if (text.charCodeAt(pos + 1) === CharacterCodes.slash && languageVariant === LanguageVariant.JSX) { + return pos += 2, token = SyntaxKind.LessThanSlashToken; + } return pos++, token = SyntaxKind.LessThanToken; case CharacterCodes.equals: if (isConflictMarkerTrivia(text, pos)) { @@ -1460,6 +1496,62 @@ namespace ts { return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken(): SyntaxKind { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + + function scanJsxToken(): SyntaxKind { + startPos = tokenPos = pos; + + if (pos >= end) { + return token = SyntaxKind.EndOfFileToken; + } + + let char = text.charCodeAt(pos); + if (char === CharacterCodes.lessThan) { + if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + return token = SyntaxKind.LessThanSlashToken; + } + pos++; + return token = SyntaxKind.LessThanToken; + } + + if (char === CharacterCodes.openBrace) { + pos++; + return token = SyntaxKind.OpenBraceToken; + } + + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) { + break; + } + } + return token = SyntaxKind.JsxText; + } + + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier(): SyntaxKind { + if (token === SyntaxKind.Identifier) { + let firstCharPosition = pos; + while (pos < end) { + let ch = text.charCodeAt(pos); + if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + function speculationHelper(callback: () => T, isLookahead: boolean): T { let savePos = pos; let saveStartPos = startPos; @@ -1504,6 +1596,10 @@ namespace ts { languageVersion = scriptTarget; } + function setLanguageVariant(variant: LanguageVariant) { + languageVariant = variant; + } + function setTextPos(textPos: number) { Debug.assert(textPos >= 0); pos = textPos; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2903c3a31f4..2a01774fbca 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -191,7 +191,8 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.watch) { + // Firefox has Object.prototype.watch + if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3d9d4151079..eed84ed59fd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -48,6 +48,7 @@ namespace ts { SemicolonToken, CommaToken, LessThanToken, + LessThanSlashToken, GreaterThanToken, LessThanEqualsToken, GreaterThanEqualsToken, @@ -220,6 +221,8 @@ namespace ts { ClassExpression, OmittedExpression, ExpressionWithTypeArguments, + AsExpression, + // Misc TemplateSpan, SemicolonClassElement, @@ -268,6 +271,16 @@ namespace ts { // Module references ExternalModuleReference, + //JSX + JsxElement, + JsxSelfClosingElement, + JsxOpeningElement, + JsxText, + JsxClosingElement, + JsxAttribute, + JsxSpreadAttribute, + JsxExpression, + // Clauses CaseClause, DefaultClause, @@ -403,6 +416,17 @@ namespace ts { HasAggregatedChildData = 1 << 7 } + export const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1 << 0, + IntrinsicIndexedElement = 1 << 1, + ClassElement = 1 << 2, + UnknownElement = 1 << 3, + + IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement + } + + /* @internal */ export const enum RelationComparisonResult { Succeeded = 1, // Should be truthy @@ -808,13 +832,66 @@ namespace ts { template: LiteralExpression | TemplateExpression; } - export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + + export interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } export interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } + export type AssertionExpression = TypeAssertion | AsExpression; + + /// A JSX expression of the form ... + export interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + + /// The opening element of a ... JsxElement + export interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + + /// A JSX expression of the form + export interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + + /// Either the opening tag in a ... pair, or the lone in a self-closing form + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + + export interface JsxAttribute extends Node { + name: Identifier; + /// JSX attribute initializers are optional; is sugar for + initializer?: Expression; + } + + export interface JsxSpreadAttribute extends Node { + expression: Expression; + } + + export interface JsxClosingElement extends Node { + tagName: EntityName; + } + + export interface JsxExpression extends Expression { + expression?: Expression; + } + + export interface JsxText extends Node { + _jsxTextExpressionBrand: any; + } + + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; + export interface Statement extends Node { _statementBrand: any; } @@ -1155,6 +1232,7 @@ namespace ts { amdDependencies: {path: string; name: string}[]; moduleName: string; referencedFiles: FileReference[]; + languageVariant: LanguageVariant; /** * lib.d.ts should have a reference comment like @@ -1223,11 +1301,11 @@ namespace ts { */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - /* @internal */ getCompilerOptionsDiagnostics(): Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source fils in the program. @@ -1334,6 +1412,9 @@ namespace ts { getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; + // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; @@ -1619,6 +1700,8 @@ namespace ts { assignmentChecks?: Map; // Cache of assignment checks hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side + jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with + resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element } export const enum TypeFlags { @@ -1685,10 +1768,8 @@ namespace ts { typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none) localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none) - } - - export interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; + resolvedBaseConstructorType?: Type; // Resolved base constructor type of class + resolvedBaseTypes: ObjectType[]; // Resolved base types } export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { @@ -1852,6 +1933,7 @@ namespace ts { help?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + jsx?: JsxEmit; listFiles?: boolean; locale?: string; mapRoot?: string; @@ -1896,11 +1978,17 @@ namespace ts { System = 4, } + export const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2 + } + export const enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } - + export interface LineAndCharacter { line: number; /* @@ -1916,6 +2004,11 @@ namespace ts { Latest = ES6, } + export const enum LanguageVariant { + Standard, + JSX + } + export interface ParsedCommandLine { options: CompilerOptions; fileNames: string[]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5f062539e1c..af2ac2aa5f8 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -42,7 +42,7 @@ namespace ts { // Pool writers to avoid needing to allocate them for every symbol we write. let stringWriters: StringSymbolWriter[] = []; export function getSingleLineStringWriter(): StringSymbolWriter { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { let str = ""; let writeText: (text: string) => void = text => str += text; @@ -169,13 +169,13 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } - export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string { + export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string { if (nodeIsMissing(node)) { return ""; } let text = sourceFile.text; - return text.substring(skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : skipTrivia(text, node.pos), node.end); } export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string { @@ -186,8 +186,8 @@ namespace ts { return sourceText.substring(skipTrivia(sourceText, node.pos), node.end); } - export function getTextOfNode(node: Node): string { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + export function getTextOfNode(node: Node, includeTrivia = false): string { + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' @@ -274,7 +274,7 @@ namespace ts { } export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan { - let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.text, /*onError:*/ undefined, pos); + let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); let start = scanner.getTokenPos(); return createTextSpanFromBounds(start, scanner.getTextPos()); @@ -426,7 +426,7 @@ namespace ts { // Specialized signatures can have string literals as their parameters' type names return node.parent.kind === SyntaxKind.Parameter; case SyntaxKind.ExpressionWithTypeArguments: - return true; + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container @@ -460,7 +460,7 @@ namespace ts { } switch (parent.kind) { case SyntaxKind.ExpressionWithTypeArguments: - return true; + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case SyntaxKind.TypeParameter: return node === (parent).constraint; case SyntaxKind.PropertyDeclaration: @@ -542,6 +542,7 @@ namespace ts { case SyntaxKind.ModuleDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -579,26 +580,15 @@ namespace ts { return true; } } - return false; } export function isAccessor(node: Node): boolean { - if (node) { - switch (node.kind) { - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - return true; - } - } - - return false; + return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); } export function isClassLike(node: Node): boolean { - if (node) { - return node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression; - } + return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); } export function isFunctionLike(node: Node): boolean { @@ -620,7 +610,6 @@ namespace ts { return true; } } - return false; } @@ -640,7 +629,16 @@ namespace ts { } } } - + + export function getContainingClass(node: Node): ClassLikeDeclaration { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node { while (true) { node = node.parent; @@ -653,7 +651,7 @@ namespace ts { // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container // so that we can error on it. - if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { + if (isClassLike(node.parent.parent)) { return node; } // If this is a computed property, then the parent should not @@ -708,7 +706,7 @@ namespace ts { // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { + if (isClassLike(node.parent.parent)) { return node; } // If this is a computed property, then the parent should not @@ -770,8 +768,8 @@ namespace ts { return (node).tag; } - // Will either be a CallExpression or NewExpression. - return (node).expression; + // Will either be a CallExpression, NewExpression, or Decorator. + return (node).expression; } export function nodeCanBeDecorated(node: Node): boolean { @@ -866,6 +864,7 @@ namespace ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AsExpression: case SyntaxKind.TypeAssertionExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.FunctionExpression: @@ -882,13 +881,14 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.OmittedExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.YieldExpression: return true; case SyntaxKind.QualifiedName: while (node.parent.kind === SyntaxKind.QualifiedName) { node = node.parent; } - return node.parent.kind === SyntaxKind.TypeQuery; case SyntaxKind.Identifier: if (node.parent.kind === SyntaxKind.TypeQuery) { @@ -929,13 +929,16 @@ namespace ts { return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || forInStatement.expression === node; case SyntaxKind.TypeAssertionExpression: - return node === (parent).expression; + case SyntaxKind.AsExpression: + return node === (parent).expression; case SyntaxKind.TemplateSpan: return node === (parent).expression; case SyntaxKind.ComputedPropertyName: return node === (parent).expression; case SyntaxKind.Decorator: return true; + case SyntaxKind.ExpressionWithTypeArguments: + return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: if (isExpression(parent)) { return true; @@ -1082,7 +1085,7 @@ namespace ts { return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken; } - export function isBindingPattern(node: Node) { + export function isBindingPattern(node: Node): node is BindingPattern { return !!node && (node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern); } @@ -1102,6 +1105,7 @@ namespace ts { case SyntaxKind.ArrowFunction: case SyntaxKind.BindingElement: case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.Constructor: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: @@ -1250,7 +1254,7 @@ namespace ts { return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - export function getClassImplementsHeritageClauseElements(node: ClassDeclaration) { + export function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration) { let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword); return heritageClause ? heritageClause.types : undefined; } @@ -1551,6 +1555,11 @@ namespace ts { } } + export function isIntrinsicJsxName(name: string) { + let ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + function get16BitUnicodeEscapeSequence(charCode: number): string { let hexCharCode = charCode.toString(16).toUpperCase(); let paddedHexCode = ("0000" + hexCharCode).slice(-4); @@ -1907,6 +1916,8 @@ namespace ts { case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.ParenthesizedExpression: @@ -1935,6 +1946,12 @@ namespace ts { return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment; } + export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean { + return node.kind === SyntaxKind.ExpressionWithTypeArguments && + (node.parent).token === SyntaxKind.ExtendsKeyword && + isClassLike(node.parent.parent); + } + // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). export function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean { @@ -1966,6 +1983,10 @@ namespace ts { return fileExtensionIs(fileName, ".js"); } + export function isTsx(fileName: string) { + return fileExtensionIs(fileName, ".tsx"); + } + /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. @@ -1973,7 +1994,6 @@ namespace ts { function getExpandedCharCodes(input: string): number[] { let output: number[] = []; let length = input.length; - let leadSurrogate: number = undefined; for (let i = 0; i < length; i++) { let charCode = input.charCodeAt(i); @@ -2105,6 +2125,12 @@ namespace ts { return start <= textSpanEnd(span) && end >= span.start; } + export function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number) { + let end1 = start1 + length1; + let end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + export function textSpanIntersectsWithPosition(span: TextSpan, position: number) { return position <= textSpanEnd(span) && position >= span.start; } diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 21e88b9e41a..1b399e1b706 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -149,7 +149,7 @@ class CompilerBaselineRunner extends RunnerBase { // check errors it('Correct errors for ' + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => { + Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.tsx?$/, '.errors.txt'), (): string => { if (result.errors.length === 0) return null; return getErrorBaseline(toBeCompiled, otherFiles, result); }); @@ -159,7 +159,7 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it('Correct sourcemap content for ' + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { - Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => { + Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.tsx?$/, '.sourcemap.txt'), () => { var record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. @@ -177,7 +177,7 @@ class CompilerBaselineRunner extends RunnerBase { } // check js output - Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.ts/, '.js'), () => { + Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.tsx?/, '.js'), () => { var tsCode = ''; var tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { @@ -235,7 +235,7 @@ class CompilerBaselineRunner extends RunnerBase { throw new Error('Number of sourcemap files should be same as js files.'); } - Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => { + Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.tsx?/, '.js.map'), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. // Baselining isn't required here because there is no output. @@ -320,11 +320,11 @@ class CompilerBaselineRunner extends RunnerBase { let pullExtension = isSymbolBaseLine ? '.symbols.pull' : '.types.pull'; if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.ts/, pullExtension), () => pullBaseLine); + Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); } else { - Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); } } @@ -391,7 +391,7 @@ class CompilerBaselineRunner extends RunnerBase { // this will set up a series of describe/it blocks to run between the setup and cleanup phases if (this.tests.length === 0) { - var testFiles = this.enumerateFiles(this.basePath, /\.ts$/, { recursive: true }); + var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); testFiles.forEach(fn => { fn = fn.replace(/\\/g, "/"); this.checkTestCodeOutput(fn); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index bf6e120ec3c..0717ed68e83 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -660,8 +660,7 @@ module FourSlash { } errorMsg += "]\n"; - Harness.IO.log(errorMsg); - this.raiseError("Member list is not empty at Caret"); + this.raiseError("Member list is not empty at Caret: " + errorMsg); } } @@ -744,7 +743,7 @@ module FourSlash { var reference = references[i]; if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) { - this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); + this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); } return; } @@ -831,6 +830,7 @@ module FourSlash { if (expectedText !== undefined) { assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text")); } + // TODO: should be '==='? if (expectedDocumentation != undefined) { assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment")); } @@ -838,6 +838,7 @@ module FourSlash { if (expectedText !== undefined) { assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text")); } + // TODO: should be '==='? if (expectedDocumentation != undefined) { assert.equal(actualQuickInfoDocumentation, expectedDocumentation, assertionMessage("quick info doc")); } @@ -883,8 +884,16 @@ module FourSlash { this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments); var ranges = this.getRanges(); + + if (!references) { + if (ranges.length !== 0) { + this.raiseError(`Expected ${ranges.length} rename locations; got none.`); + } + return; + } + if (ranges.length !== references.length) { - this.raiseError(this.assertionMessage("Rename locations", references.length, ranges.length)); + this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); } ranges = ranges.sort((r1, r2) => r1.start - r2.start); @@ -897,9 +906,7 @@ module FourSlash { if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { - this.raiseError(this.assertionMessage("Rename location", - "[" + reference.textSpan.start + "," + ts.textSpanEnd(reference.textSpan) + ")", - "[" + range.start + "," + range.end + ")")); + this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); } } } @@ -1820,7 +1827,7 @@ module FourSlash { } private verifyProjectInfo(expected: string[]) { - if (this.testType == FourSlashTestType.Server) { + if (this.testType === FourSlashTestType.Server) { let actual = (this.languageService).getProjectInfo( this.activeFile.fileName, /* needFileNameList */ true @@ -1937,7 +1944,7 @@ module FourSlash { } } - if (expected != actual) { + if (expected !== actual) { this.raiseError('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.'); } } @@ -1984,7 +1991,7 @@ module FourSlash { var items = this.languageService.getNavigationBarItems(this.activeFile.fileName); var actual = this.getNavigationBarItemsCount(items); - if (expected != actual) { + if (expected !== actual) { this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.'); } } @@ -2402,6 +2409,7 @@ module FourSlash { globalOptions[match[1]] = match[2]; } } + // TODO: should be '==='? } else if (line == '' || lineLength === 0) { // Previously blank lines between fourslash content caused it to be considered as 2 files, // Remove this behavior since it just causes errors now diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8e8fb8d9acb..9f26887ff90 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -212,7 +212,7 @@ module Utils { } var result = ""; - ts.forEach(Object.getOwnPropertyNames(flags),(v: any) => { + ts.forEach(Object.getOwnPropertyNames(flags), (v: any) => { if (isFinite(v)) { v = +v; if (f === +v) { @@ -410,7 +410,7 @@ module Harness { deleteFile(fileName: string): void; listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; - getMemoryUsage? (): number; + getMemoryUsage?(): number; } module IOImpl { @@ -794,7 +794,7 @@ module Harness { public reset() { this.fileCollection = {}; } - public toArray(): { fileName: string; file: WriterAggregator; }[]{ + public toArray(): { fileName: string; file: WriterAggregator; }[] { var result: { fileName: string; file: WriterAggregator; }[] = []; for (var p in this.fileCollection) { if (this.fileCollection.hasOwnProperty(p)) { @@ -1170,6 +1170,12 @@ module Harness { options.inlineSources = setting.value === 'true'; break; + case 'jsx': + options.jsx = setting.value.toLowerCase() === 'react' ? ts.JsxEmit.React : + setting.value.toLowerCase() === 'preserve' ? ts.JsxEmit.Preserve : + ts.JsxEmit.None; + break; + default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1233,7 +1239,7 @@ module Harness { } var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; - + return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); } @@ -1432,6 +1438,10 @@ module Harness { return stringEndsWith(fileName, '.ts'); } + export function isTSX(fileName: string) { + return stringEndsWith(fileName, '.tsx'); + } + export function isDTS(fileName: string) { return stringEndsWith(fileName, '.d.ts'); } @@ -1439,6 +1449,9 @@ module Harness { export function isJS(fileName: string) { return stringEndsWith(fileName, '.js'); } + export function isJSX(fileName: string) { + return stringEndsWith(fileName, '.jsx'); + } export function isJSMap(fileName: string) { return stringEndsWith(fileName, '.js.map'); @@ -1459,12 +1472,15 @@ module Harness { if (isDTS(emittedFile.fileName)) { // .d.ts file, add to declFiles emit this.declFilesCode.push(emittedFile); - } else if (isJS(emittedFile.fileName)) { + } + else if (isJS(emittedFile.fileName) || isJSX(emittedFile.fileName)) { // .js file, add to files this.files.push(emittedFile); - } else if (isJSMap(emittedFile.fileName)) { + } + else if (isJSMap(emittedFile.fileName)) { this.sourceMaps.push(emittedFile); - } else { + } + else { throw new Error('Unrecognized file extension for file ' + emittedFile.fileName); } }); @@ -1499,6 +1515,16 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines + // List of allowed metadata names + var fileMetadataNames = ["filename", "comments", "declaration", "module", + "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", + "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", + "errortruncation", "usecasesensitivefilenames", "preserveconstenums", + "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", + "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", + "inlinesources", "emitdecoratormetadata", "experimentaldecorators", + "skipdefaultlibcheck", "jsx"]; + function extractCompilerSettings(content: string): CompilerSetting[] { var opts: CompilerSetting[] = []; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 0e0b8d82918..8eb77817533 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -583,7 +583,7 @@ module Harness.LanguageService { // This host is just a proxy for the clientHost, it uses the client // host to answer server queries about files on disk var serverHost = new SessionServerHost(clientHost); - var server = new ts.server.Session(serverHost, serverHost); + var server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost); // Fake the connection between the client and the server serverHost.writeMessage = client.onMessage.bind(client); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 324524272e0..5eb0016ff8d 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -110,6 +110,7 @@ class ProjectRunner extends RunnerBase { else if (url.indexOf(diskProjectPath) === 0) { // Replace the disk specific path into the project root path url = url.substr(diskProjectPath.length); + // TODO: should be '!=='? if (url.charCodeAt(0) != ts.CharacterCodes.slash) { url = "/" + url; } @@ -240,7 +241,7 @@ class ProjectRunner extends RunnerBase { if (Harness.Compiler.isJS(fileName)) { // Make sure if there is URl we have it cleaned up var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL="); - if (indexOfSourceMapUrl != -1) { + if (indexOfSourceMapUrl !== -1) { data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21)); } } diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 269e889704c..fa8d9d2c597 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -27,7 +27,7 @@ class RunnerBase { var fixedPath = path; // full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point - var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.ts/g; + var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; var fullPathList = fixedPath.match(fullPath); if (fullPathList) { fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match))); diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 528e6ddd52b..ed079774d94 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -46,7 +46,7 @@ module Harness.SourceMapRecoder { } function isSourceMappingSegmentEnd() { - if (decodingIndex == sourceMapMappings.length) { + if (decodingIndex === sourceMapMappings.length) { return true; } @@ -95,7 +95,7 @@ module Harness.SourceMapRecoder { var currentByte = base64FormatDecode(); // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) != 0; + moreDigits = (currentByte & 32) !== 0; // least significant 5 bits are the next msbs in the final value. value = value | ((currentByte & 31) << shiftCount); @@ -103,7 +103,7 @@ module Harness.SourceMapRecoder { } // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) == 0) { + if ((value & 1) === 0) { // + number value = value >> 1; } @@ -182,7 +182,7 @@ module Harness.SourceMapRecoder { } } // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex == -1 ? "sourceColumn" : "nameIndex"))) { + if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex === -1 ? "sourceColumn" : "nameIndex"))) { return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping }; } @@ -249,7 +249,7 @@ module Harness.SourceMapRecoder { mapString += " name (" + sourceMapNames[mapEntry.nameIndex] + ")"; } else { - if (mapEntry.nameIndex != -1 || getAbsentNameIndex) { + if (mapEntry.nameIndex !== -1 || getAbsentNameIndex) { mapString += " nameIndex (" + mapEntry.nameIndex + ")"; } } @@ -262,12 +262,12 @@ module Harness.SourceMapRecoder { var decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan(); var decodedErrors: string[]; if (decodeResult.error - || decodeResult.sourceMapSpan.emittedLine != sourceMapSpan.emittedLine - || decodeResult.sourceMapSpan.emittedColumn != sourceMapSpan.emittedColumn - || decodeResult.sourceMapSpan.sourceLine != sourceMapSpan.sourceLine - || decodeResult.sourceMapSpan.sourceColumn != sourceMapSpan.sourceColumn - || decodeResult.sourceMapSpan.sourceIndex != sourceMapSpan.sourceIndex - || decodeResult.sourceMapSpan.nameIndex != sourceMapSpan.nameIndex) { + || decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine + || decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn + || decodeResult.sourceMapSpan.sourceLine !== sourceMapSpan.sourceLine + || decodeResult.sourceMapSpan.sourceColumn !== sourceMapSpan.sourceColumn + || decodeResult.sourceMapSpan.sourceIndex !== sourceMapSpan.sourceIndex + || decodeResult.sourceMapSpan.nameIndex !== sourceMapSpan.nameIndex) { if (decodeResult.error) { decodedErrors = ["!!^^ !!^^ There was decoding error in the sourcemap at this location: " + decodeResult.error]; } @@ -288,7 +288,7 @@ module Harness.SourceMapRecoder { } export function recordNewSourceFileSpan(sourceMapSpan: ts.SourceMapSpan, newSourceFileCode: string) { - assert.isTrue(spansOnSingleLine.length == 0 || spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine, "new file source map span should be on new line. We currently handle only that scenario"); + assert.isTrue(spansOnSingleLine.length === 0 || spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine, "new file source map span should be on new line. We currently handle only that scenario"); recordSourceMapSpan(sourceMapSpan); assert.isTrue(spansOnSingleLine.length === 1); @@ -395,9 +395,9 @@ module Harness.SourceMapRecoder { var tsCodeLineMap = ts.computeLineStarts(sourceText); for (var i = 0; i < tsCodeLineMap.length; i++) { - writeSourceMapIndent(prevEmittedCol, i == 0 ? markerIds[index] : " >"); + writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >"); sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText)); - if (i == tsCodeLineMap.length - 1) { + if (i === tsCodeLineMap.length - 1) { sourceMapRecoder.WriteLine(""); } } @@ -447,7 +447,7 @@ module Harness.SourceMapRecoder { for (var j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) { var decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j]; var currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]); - if (currentSourceFile != prevSourceFile) { + if (currentSourceFile !== prevSourceFile) { SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text); prevSourceFile = currentSourceFile; } diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 533f90a2d83..b68e606c79d 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -41,7 +41,10 @@ class TypeWriterWalker { var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos); var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node); - var type = this.checker.getTypeAtLocation(node); + // Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions + // var type = this.checker.getTypeAtLocation(node); + var type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node); + ts.Debug.assert(type !== undefined, "type doesn't exist"); var symbol = this.checker.getSymbolAtLocation(node); diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 35ed970fde1..f3c0a1418fe 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -694,6 +694,7 @@ interface Map { } interface MapConstructor { + new (): Map; new (): Map; new (iterable: Iterable<[K, V]>): Map; prototype: Map; @@ -710,6 +711,7 @@ interface WeakMap { } interface WeakMapConstructor { + new (): WeakMap; new (): WeakMap; new (iterable: Iterable<[K, V]>): WeakMap; prototype: WeakMap; @@ -731,6 +733,7 @@ interface Set { } interface SetConstructor { + new (): Set; new (): Set; new (iterable: Iterable): Set; prototype: Set; @@ -746,6 +749,7 @@ interface WeakSet { } interface WeakSetConstructor { + new (): WeakSet; new (): WeakSet; new (iterable: Iterable): WeakSet; prototype: WeakSet; diff --git a/src/lib/intl.d.ts b/src/lib/intl.d.ts index 66e51ddbc5a..57df70672d4 100644 --- a/src/lib/intl.d.ts +++ b/src/lib/intl.d.ts @@ -41,6 +41,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -103,7 +108,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/src/server/client.ts b/src/server/client.ts index 3546f8339ee..e4a524dd210 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -219,7 +219,7 @@ namespace ts.server { var request = this.processRequest(CommandNames.CompletionDetails, args); var response = this.processResponse(request); - Debug.assert(response.body.length == 1, "Unexpected length of completion details response body."); + Debug.assert(response.body.length === 1, "Unexpected length of completion details response body."); return response.body[0]; } @@ -429,8 +429,8 @@ namespace ts.server { if (!this.lastRenameEntry || this.lastRenameEntry.fileName !== fileName || this.lastRenameEntry.position !== position || - this.lastRenameEntry.findInStrings != findInStrings || - this.lastRenameEntry.findInComments != findInComments) { + this.lastRenameEntry.findInStrings !== findInStrings || + this.lastRenameEntry.findInComments !== findInComments) { this.getRenameInfo(fileName, position, findInStrings, findInComments); } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9e235e2cc7d..91d400ff263 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2,7 +2,6 @@ /// /// /// -/// namespace ts.server { export interface Logger { @@ -28,7 +27,7 @@ namespace ts.server { }); } - class ScriptInfo { + export class ScriptInfo { svc: ScriptVersionCache; children: ScriptInfo[] = []; // files referenced by this file defaultProject: Project; // project to use by default for file @@ -36,7 +35,7 @@ namespace ts.server { formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) { - this.svc = ScriptVersionCache.fromString(content); + this.svc = ScriptVersionCache.fromString(host, content); } setFormatOptions(formatOptions: protocol.FormatOptions): void { @@ -80,7 +79,7 @@ namespace ts.server { } } - class LSHost implements ts.LanguageServiceHost { + export class LSHost implements ts.LanguageServiceHost { ls: ts.LanguageService = null; compilationSettings: ts.CompilerOptions; filenameToScript: ts.Map = {}; @@ -273,7 +272,7 @@ namespace ts.server { } } - interface ProjectOptions { + export interface ProjectOptions { // these fields can be present in the project file files?: string[]; compilerOptions?: ts.CompilerOptions; @@ -376,7 +375,7 @@ namespace ts.server { } } - interface ProjectOpenResult { + export interface ProjectOpenResult { success?: boolean; errorMsg?: string; project?: Project; @@ -392,11 +391,11 @@ namespace ts.server { return copiedList; } - interface ProjectServiceEventHandler { + export interface ProjectServiceEventHandler { (eventName: string, project: Project, fileName: string): void; } - interface HostConfiguration { + export interface HostConfiguration { formatCodeOptions: ts.FormatCodeOptions; hostInfo: string; } @@ -629,7 +628,7 @@ namespace ts.server { for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var f = this.openFilesReferenced[i]; // if f was referenced by the removed project, remember it - if (f.defaultProject == removedProject) { + if (f.defaultProject === removedProject) { f.defaultProject = undefined; orphanFiles.push(f); } @@ -656,7 +655,7 @@ namespace ts.server { for (var i = 0, len = this.inferredProjects.length; i < len; i++) { var inferredProject = this.inferredProjects[i]; inferredProject.updateGraph(); - if (inferredProject != excludedProject) { + if (inferredProject !== excludedProject) { if (inferredProject.getSourceFile(info)) { info.defaultProject = inferredProject; referencingProjects.push(inferredProject); @@ -710,7 +709,7 @@ namespace ts.server { var rootFile = this.openFileRoots[i]; var rootedProject = rootFile.defaultProject; var referencingProjects = this.findReferencingProjects(rootFile, rootedProject); - if (referencingProjects.length == 0) { + if (referencingProjects.length === 0) { rootFile.defaultProject = rootedProject; openFileRoots.push(rootFile); } @@ -916,7 +915,7 @@ namespace ts.server { return rawConfig.error; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath); + var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } @@ -953,7 +952,7 @@ namespace ts.server { } - class CompilerService { + export class CompilerService { host: LSHost; languageService: ts.LanguageService; classifier: ts.Classifier; @@ -985,7 +984,7 @@ namespace ts.server { static defaultFormatCodeOptions: ts.FormatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys.newLine, + NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', ConvertTabsToSpaces: true, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, @@ -999,7 +998,7 @@ namespace ts.server { } - interface LineCollection { + export interface LineCollection { charCount(): number; lineCount(): number; isLeaf(): boolean; @@ -1013,7 +1012,7 @@ namespace ts.server { leaf?: LineLeaf; } - enum CharRangeSection { + export enum CharRangeSection { PreStart, Start, Entire, @@ -1022,7 +1021,7 @@ namespace ts.server { PostEnd } - interface ILineIndexWalker { + export interface ILineIndexWalker { goSubtree: boolean; done: boolean; leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void; @@ -1082,7 +1081,7 @@ namespace ts.server { for (var k = this.endBranch.length - 1; k >= 0; k--) { (this.endBranch[k]).updateCounts(); - if (this.endBranch[k].charCount() == 0) { + if (this.endBranch[k].charCount() === 0) { lastZeroCount = this.endBranch[k]; if (k > 0) { branchParent = this.endBranch[k - 1]; @@ -1147,7 +1146,7 @@ namespace ts.server { post(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection): LineCollection { // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition - if (lineCollection == this.lineCollectionAtBranch) { + if (lineCollection === this.lineCollectionAtBranch) { this.state = CharRangeSection.End; } // always pop stack because post only called when child has been visited @@ -1159,7 +1158,7 @@ namespace ts.server { // currentNode corresponds to parent, but in the new tree var currentNode = this.stack[this.stack.length - 1]; - if ((this.state == CharRangeSection.Entire) && (nodeType == CharRangeSection.Start)) { + if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { // if range is on single line, we will never make this state transition this.state = CharRangeSection.Start; this.branchNode = currentNode; @@ -1176,12 +1175,12 @@ namespace ts.server { switch (nodeType) { case CharRangeSection.PreStart: this.goSubtree = false; - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { currentNode.add(lineCollection); } break; case CharRangeSection.Start: - if (this.state == CharRangeSection.End) { + if (this.state === CharRangeSection.End) { this.goSubtree = false; } else { @@ -1191,7 +1190,7 @@ namespace ts.server { } break; case CharRangeSection.Entire: - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { child = fresh(lineCollection); currentNode.add(child); this.startPath[this.startPath.length] = child; @@ -1208,7 +1207,7 @@ namespace ts.server { this.goSubtree = false; break; case CharRangeSection.End: - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { this.goSubtree = false; } else { @@ -1221,7 +1220,7 @@ namespace ts.server { break; case CharRangeSection.PostEnd: this.goSubtree = false; - if (this.state != CharRangeSection.Start) { + if (this.state !== CharRangeSection.Start) { currentNode.add(lineCollection); } break; @@ -1233,10 +1232,10 @@ namespace ts.server { } // just gather text from the leaves leaf(relativeStart: number, relativeLength: number, ll: LineLeaf) { - if (this.state == CharRangeSection.Start) { + if (this.state === CharRangeSection.Start) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state == CharRangeSection.Entire) { + else if (this.state === CharRangeSection.Entire) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -1248,7 +1247,7 @@ namespace ts.server { } // text change information - class TextChange { + export class TextChange { constructor(public pos: number, public deleteLen: number, public insertedText?: string) { } @@ -1263,6 +1262,7 @@ namespace ts.server { versions: LineIndexSnapshot[] = []; minVersion = 0; // no versions earlier than min version will maintain change history private currentVersion = 0; + private host: ServerHost; static changeNumberThreshold = 8; static changeLengthThreshold = 256; @@ -1290,7 +1290,7 @@ namespace ts.server { } reloadFromFile(filename: string, cb?: () => any) { - var content = ts.sys.readFile(filename); + var content = this.host.readFile(filename); this.reload(content); if (cb) cb(); @@ -1360,10 +1360,11 @@ namespace ts.server { } } - static fromString(script: string) { + static fromString(host: ServerHost, script: string) { var svc = new ScriptVersionCache(); var snap = new LineIndexSnapshot(0, svc); svc.versions[svc.currentVersion] = snap; + svc.host = host; snap.index = new LineIndex(); var lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); @@ -1371,7 +1372,7 @@ namespace ts.server { } } - class LineIndexSnapshot implements ts.IScriptSnapshot { + export class LineIndexSnapshot implements ts.IScriptSnapshot { index: LineIndex; changesSincePreviousVersion: TextChange[] = []; @@ -1499,8 +1500,8 @@ namespace ts.server { function editFlat(source: string, s: number, dl: number, nt = "") { return source.substring(0, s) + nt + source.substring(s + dl, source.length); } - if (this.root.charCount() == 0) { - // TODO: assert deleteLength == 0 + if (this.root.charCount() === 0) { + // TODO: assert deleteLength === 0 if (newText) { this.load(LineIndex.linesFromText(newText).lines); return this; @@ -1528,7 +1529,7 @@ namespace ts.server { // check whether last characters deleted are line break var e = pos + deleteLength; var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset == 0))) { + if ((lineInfo && (lineInfo.offset === 0))) { // move range end just past line that will merge with previous line deleteLength += lineInfo.text.length; // store text by appending to end of insertedText @@ -1574,7 +1575,7 @@ namespace ts.server { interiorNodes[i].totalChars = charCount; interiorNodes[i].totalLines = lineCount; } - if (interiorNodes.length == 1) { + if (interiorNodes.length === 1) { return interiorNodes[0]; } else { @@ -1585,7 +1586,7 @@ namespace ts.server { static linesFromText(text: string) { var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length == 0) { + if (lineStarts.length === 0) { return { lines: [], lineMap: lineStarts }; } var lines = new Array(lineStarts.length); @@ -1605,7 +1606,7 @@ namespace ts.server { } } - class LineNode implements LineCollection { + export class LineNode implements LineCollection { totalChars = 0; totalLines = 0; children: LineCollection[] = []; @@ -1821,7 +1822,7 @@ namespace ts.server { findChildIndex(child: LineCollection) { var childIndex = 0; var clen = this.children.length; - while ((this.children[childIndex] != child) && (childIndex < clen)) childIndex++; + while ((this.children[childIndex] !== child) && (childIndex < clen)) childIndex++; return childIndex; } @@ -1830,7 +1831,7 @@ namespace ts.server { var clen = this.children.length; var nodeCount = nodes.length; // if child is last and there is more room and only one node to place, place it - if ((clen < lineCollectionCapacity) && (childIndex == (clen - 1)) && (nodeCount == 1)) { + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { this.add(nodes[0]); this.updateCounts(); return []; @@ -1854,13 +1855,13 @@ namespace ts.server { var splitNode = splitNodes[0]; while (nodeIndex < nodeCount) { splitNode.add(nodes[nodeIndex++]); - if (splitNode.children.length == lineCollectionCapacity) { + if (splitNode.children.length === lineCollectionCapacity) { splitNodeIndex++; splitNode = splitNodes[splitNodeIndex]; } } for (i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length == 0) { + if (splitNodes[i].children.length === 0) { splitNodes.length--; } } @@ -1891,7 +1892,7 @@ namespace ts.server { } } - class LineLeaf implements LineCollection { + export class LineLeaf implements LineCollection { udata: any; constructor(public text: string) { diff --git a/src/server/node.d.ts b/src/server/node.d.ts index 2002f973a37..8f7237382e5 100644 --- a/src/server/node.d.ts +++ b/src/server/node.d.ts @@ -584,9 +584,9 @@ declare module NodeJS { export interface Response extends Message { request_seq: number; success: boolean; - /** Contains error message if success == false. */ + /** Contains error message if success === false. */ message?: string; - /** Contains message body if success == true. */ + /** Contains message body if success === true. */ body?: any; } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 336bc11c9f3..017a8c1d81a 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -67,12 +67,12 @@ declare namespace ts.server.protocol { command: string; /** - * Contains error message if success == false. + * Contains error message if success === false. */ message?: string; /** - * Contains message body if success == true. + * Contains message body if success === true. */ body?: any; } diff --git a/src/server/server.ts b/src/server/server.ts index b4b35edd3f3..843197b918a 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -11,7 +11,7 @@ namespace ts.server { input: process.stdin, output: process.stdout, terminal: false, - }); + }); class Logger implements ts.server.Logger { fd = -1; @@ -123,7 +123,7 @@ namespace ts.server { if (err) { watchedFile.callback(watchedFile.fileName); } - else if (watchedFile.mtime.getTime() != stats.mtime.getTime()) { + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); watchedFile.callback(watchedFile.fileName); } @@ -138,7 +138,7 @@ namespace ts.server { var count = 0; var nextToCheck = this.nextFileToCheck; var firstCheck = -1; - while ((count < this.chunkSize) && (nextToCheck != firstCheck)) { + while ((count < this.chunkSize) && (nextToCheck !== firstCheck)) { this.poll(nextToCheck); if (firstCheck < 0) { firstCheck = nextToCheck; @@ -170,11 +170,11 @@ namespace ts.server { removeFile(file: WatchedFile) { this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles); } - } + } class IOSession extends Session { constructor(host: ServerHost, logger: ts.server.Logger) { - super(host, logger); + super(host, Buffer.byteLength, process.hrtime, logger); } exit() { diff --git a/src/server/session.ts b/src/server/session.ts index f9cfb4f9f7d..c95b1a7cc1b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1,6 +1,5 @@ /// /// -/// /// /// @@ -31,7 +30,7 @@ namespace ts.server { if (a < b) { return -1; } - else if (a == b) { + else if (a === b) { return 0; } else return 1; @@ -43,7 +42,7 @@ namespace ts.server { } else if (a.file == b.file) { var n = compareNumber(a.start.line, b.start.line); - if (n == 0) { + if (n === 0) { return compareNumber(a.start.offset, b.start.offset); } else return n; @@ -61,7 +60,7 @@ namespace ts.server { }; } - interface PendingErrorCheck { + export interface PendingErrorCheck { fileName: string; project: Project; } @@ -114,11 +113,16 @@ namespace ts.server { pendingOperation = false; fileHash: ts.Map = {}; nextFileId = 1; - errorTimer: NodeJS.Timer; + errorTimer: any; /*NodeJS.Timer | number*/ immediateId: any; changeSeq = 0; - constructor(private host: ServerHost, private logger: Logger) { + constructor( + private host: ServerHost, + private byteLength: (buf: string, encoding?: string) => number, + private hrtime: (start?: number[]) => number[], + private logger: Logger + ) { this.projectService = new ProjectService(host, logger, (eventName,project,fileName) => { this.handleEvent(eventName, project, fileName); @@ -129,7 +133,7 @@ namespace ts.server { if (eventName == "context") { this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); this.updateErrorCheck([{ fileName, project }], this.changeSeq, - (n) => n == this.changeSeq, 100); + (n) => n === this.changeSeq, 100); } } @@ -149,17 +153,17 @@ namespace ts.server { this.host.write(line + this.host.newLine); } - send(msg: NodeJS._debugger.Message) { + send(msg: protocol.Message) { var json = JSON.stringify(msg); if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); } - this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) + + this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + '\r\n\r\n' + json); } event(info: any, eventName: string) { - var ev: NodeJS._debugger.Event = { + var ev: protocol.Event = { seq: 0, type: "event", event: eventName, @@ -546,7 +550,7 @@ namespace ts.server { // getFormattingEditsAfterKeytroke either empty or pertaining // only to the previous line. If all this is true, then // add edits necessary to properly indent the current line. - if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) { + if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { var scriptInfo = compilerService.host.getScriptInfo(file); if (scriptInfo) { var lineInfo = scriptInfo.getLineInfo(line); @@ -622,7 +626,7 @@ namespace ts.server { } return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) == 0)) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { result.push(entry); } return result; @@ -689,7 +693,7 @@ namespace ts.server { }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq,(n) => n == this.changeSeq, delay) + this.updateErrorCheck(checkList, this.changeSeq,(n) => n === this.changeSeq, delay) } } @@ -704,7 +708,7 @@ namespace ts.server { compilerService.host.editScript(file, start, end, insertString); this.changeSeq++; } - this.updateProjectStructure(this.changeSeq, (n) => n == this.changeSeq); + this.updateProjectStructure(this.changeSeq, (n) => n === this.changeSeq); } } @@ -838,7 +842,7 @@ namespace ts.server { onMessage(message: string) { if (this.logger.isVerbose()) { this.logger.info("request: " + message); - var start = process.hrtime(); + var start = this.hrtime(); } try { var request = JSON.parse(message); @@ -980,7 +984,7 @@ namespace ts.server { } if (this.logger.isVerbose()) { - var elapsed = process.hrtime(start); + var elapsed = this.hrtime(start); var seconds = elapsed[0] var nanoseconds = elapsed[1]; var elapsedMs = ((1e9 * seconds) + nanoseconds)/1000000.0; diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 4d3d7d331a5..227ba6a7970 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -75,7 +75,7 @@ namespace ts.BreakpointResolver { return textSpan(node); } - if (node.parent.kind == SyntaxKind.ArrowFunction && (node.parent).body == node) { + if (node.parent.kind === SyntaxKind.ArrowFunction && (node.parent).body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index c9b9952a49e..ab182797a3c 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -59,7 +59,7 @@ namespace ts.formatting { if (this.tokensAreOnSameLine === undefined) { let startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; let endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; @@ -84,7 +84,7 @@ namespace ts.formatting { private NodeIsOnOneLine(node: Node): boolean { let startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; let endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; } private BlockIsOnOneLine(node: Node): boolean { diff --git a/src/services/formatting/ruleOperationContext.ts b/src/services/formatting/ruleOperationContext.ts index 515250d7264..47330faa0dd 100644 --- a/src/services/formatting/ruleOperationContext.ts +++ b/src/services/formatting/ruleOperationContext.ts @@ -14,7 +14,7 @@ namespace ts.formatting { public IsAny(): boolean { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; } public InContext(context: FormattingContext): boolean { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index c10e3ee69ea..da132754311 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -318,7 +318,7 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -470,6 +470,7 @@ namespace ts.formatting { switch (context.contextNode.kind) { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: + case SyntaxKind.AsExpression: case SyntaxKind.TypePredicate: return true; @@ -692,7 +693,7 @@ namespace ts.formatting { } static IsNotFormatOnEnter(context: FormattingContext): boolean { - return context.formattingRequestKind != FormattingRequestKind.FormatOnEnter; + return context.formattingRequestKind !== FormattingRequestKind.FormatOnEnter; } static IsModuleDeclContext(context: FormattingContext): boolean { diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index 4f231bd842e..bffbb75c02e 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -41,15 +41,15 @@ namespace ts.formatting { } private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void { - let specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != Shared.TokenRange.Any; + let specificRule = rule.Descriptor.LeftTokenRange !== Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => { rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => { let rulesBucketIndex = this.GetRuleBucketIndex(left, right); let rulesBucket = this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = this.map[rulesBucketIndex] = new RulesBucket(); } @@ -124,7 +124,7 @@ namespace ts.formatting { public IncreaseInsertionIndex(maskPosition: RulesPosition): void { let value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); let temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; @@ -147,7 +147,7 @@ namespace ts.formatting { public AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void { let position: RulesPosition; - if (rule.Operation.Action == RuleAction.Ignore) { + if (rule.Operation.Action === RuleAction.Ignore) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index bd8f4fc3a5e..ac1494571d1 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -25,6 +25,7 @@ namespace ts.formatting { } public ensureUpToDate(options: ts.FormatCodeOptions) { + // TODO: Should this be '==='? if (this.options == null || !ts.compareDataObjects(this.options, options)) { let activeRules = this.createActiveRules(options); let rulesMap = RulesMap.create(activeRules); diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index a82e57f050f..db748f7f494 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -26,7 +26,7 @@ namespace ts.formatting { precedingToken.kind === SyntaxKind.TemplateHead || precedingToken.kind === SyntaxKind.TemplateMiddle || precedingToken.kind === SyntaxKind.TemplateTail; - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } @@ -66,6 +66,10 @@ namespace ts.formatting { if (actualIndentation !== Value.Unknown) { return actualIndentation; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== Value.Unknown) { + return actualIndentation + options.IndentSize; + } previous = current; current = current.parent; @@ -122,6 +126,10 @@ namespace ts.formatting { if (actualIndentation !== Value.Unknown) { return actualIndentation + indentationDelta; } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== Value.Unknown) { + return actualIndentation + indentationDelta; + } } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line @@ -287,6 +295,55 @@ namespace ts.formatting { } } + function getLineIndentationWhenExpressionIsInMultiLine(node: Node, sourceFile: SourceFile, options: EditorOptions): number { + // actual indentation should not be used when: + // - node is close parenthesis - this is the end of the expression + if (node.kind === SyntaxKind.CloseParenToken) { + return Value.Unknown; + } + + if (node.parent && ( + node.parent.kind === SyntaxKind.CallExpression || + node.parent.kind === SyntaxKind.NewExpression) && + (node.parent).expression !== node) { + + let fullCallOrNewExpression = (node.parent).expression; + let startingExpression = getStartingExpression(fullCallOrNewExpression); + + if (fullCallOrNewExpression === startingExpression) { + return Value.Unknown; + } + + let fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + let startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return Value.Unknown; + } + + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + + return Value.Unknown; + + function getStartingExpression(node: PropertyAccessExpression | CallExpression | ElementAccessExpression) { + while (true) { + switch (node.kind) { + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } + function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: EditorOptions): number { Debug.assert(index >= 0 && index < list.length); let node = list[index]; diff --git a/src/services/formatting/tokenRange.ts b/src/services/formatting/tokenRange.ts index 27a43280f2c..19185cdf78d 100644 --- a/src/services/formatting/tokenRange.ts +++ b/src/services/formatting/tokenRange.ts @@ -54,7 +54,7 @@ namespace ts.formatting { } public Contains(tokenValue: SyntaxKind): boolean { - return tokenValue == this.token; + return tokenValue === this.token; } } @@ -112,7 +112,7 @@ namespace ts.formatting { static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia])); static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword); static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator); - static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.IsKeyword]); + static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]); static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]); static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index d56c7fac975..ea433867c46 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -686,7 +686,7 @@ namespace ts { if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { @@ -757,7 +757,7 @@ namespace ts { // 3) HTMLDocument -> HTML, Document // // etc. - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); let nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); diff --git a/src/services/services.ts b/src/services/services.ts index 3939e62cfd2..018a11fc4bb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -95,7 +95,6 @@ namespace ts { export module ScriptSnapshot { class StringScriptSnapshot implements IScriptSnapshot { - private _lineStartPositions: number[] = undefined; constructor(private text: string) { } @@ -167,7 +166,7 @@ namespace ts { } public getFullWidth(): number { - return this.end - this.getFullStart(); + return this.end - this.pos; } public getLeadingTriviaWidth(sourceFile?: SourceFile): number { @@ -198,8 +197,8 @@ namespace ts { list._children = []; let pos = nodes.pos; - - + + for (let node of nodes) { if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); @@ -751,6 +750,7 @@ namespace ts { public symbolCount: number; public version: string; public languageVersion: ScriptTarget; + public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: Map; @@ -875,7 +875,7 @@ namespace ts { case SyntaxKind.SetAccessor: case SyntaxKind.TypeLiteral: addDeclaration(node); - // fall through + // fall through case SyntaxKind.Constructor: case SyntaxKind.VariableStatement: case SyntaxKind.VariableDeclarationList: @@ -973,6 +973,9 @@ namespace ts { getSyntacticDiagnostics(fileName: string): Diagnostic[]; getSemanticDiagnostics(fileName: string): Diagnostic[]; + + // TODO: Rename this to getProgramDiagnostics to better indicate that these are any + // diagnostics present for the program level, and not just 'options' diagnostics. getCompilerOptionsDiagnostics(): Diagnostic[]; /** @@ -1092,7 +1095,7 @@ namespace ts { export const definition = "definition"; export const reference = "reference"; export const writtenReference = "writtenReference"; - } + } export interface HighlightSpan { textSpan: TextSpan; @@ -1607,6 +1610,7 @@ namespace ts { return { target: ScriptTarget.ES5, module: ModuleKind.None, + jsx: JsxEmit.Preserve }; } @@ -1789,18 +1793,13 @@ namespace ts { sourceFile.moduleName = moduleName; } - // Store syntactic diagnostics - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push(...sourceFile.parseDiagnostics); - } - let newLine = getNewLineCharacter(options); // Output let outputText: string; // Create a compilerHost object to allow the compiler to read and write files - var compilerHost: CompilerHost = { + let compilerHost: CompilerHost = { getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); @@ -1813,11 +1812,10 @@ namespace ts { getNewLine: () => newLine }; - var program = createProgram([inputFileName], options, compilerHost); + let program = createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push(...program.getCompilerOptionsDiagnostics()); - } + addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); // Emit program.emit(); @@ -2796,7 +2794,7 @@ namespace ts { function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } /// Completion @@ -2898,22 +2896,33 @@ namespace ts { return undefined; } + let options = program.getCompilerOptions(); + let jsx = options.jsx !== JsxEmit.None; + let target = options.target; + // Find the node where completion is requested on, in the case of a completion after // a dot, it is the member access expression other wise, it is a request for all // visible symbols in the scope, and the node is the current location. let node = currentToken; let isRightOfDot = false; - if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (contextToken.parent).expression; - isRightOfDot = true; - } - else if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { - node = (contextToken.parent).left; - isRightOfDot = true; - } + let isRightOfOpenTag = false; let location = getTouchingPropertyName(sourceFile, position); - var target = program.getCompilerOptions().target; + if(contextToken) { + let kind = contextToken.kind; + if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; + isRightOfDot = true; + } + else if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; + isRightOfDot = true; + } + else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { + isRightOfOpenTag = true; + location = contextToken; + } + } let semanticStart = new Date().getTime(); let isMemberCompletion: boolean; @@ -2923,6 +2932,17 @@ namespace ts { if (isRightOfDot) { getTypeScriptMemberSymbols(); } + else if (isRightOfOpenTag) { + let tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & SymbolFlags.Value))); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -2934,7 +2954,7 @@ namespace ts { log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -2988,22 +3008,34 @@ namespace ts { } function tryGetGlobalSymbols(): boolean { - let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); - if (containingObjectLiteral) { + let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); + if (objectLikeContainer) { // Object literal expression, look up possible property names from contextual type isMemberCompletion = true; isNewIdentifierLocation = true; - let contextualType = typeChecker.getContextualType(containingObjectLiteral); - if (!contextualType) { + let typeForObject: Type; + let existingMembers: Declaration[]; + + if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = (objectLikeContainer).properties; + } + else { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = (objectLikeContainer).elements; + } + + if (!typeForObject) { return false; } - let contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType); - if (contextualTypeMembers && contextualTypeMembers.length > 0) { + let typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { // Add filtered items to the completion list - symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); + symbols = filterObjectMembersList(typeMembers, existingMembers); } + return true; } else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { // cursor is in import clause @@ -3025,51 +3057,77 @@ namespace ts { //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; } + return true; } - else { - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + else if (getAncestor(contextToken, SyntaxKind.JsxElement) || getAncestor(contextToken, SyntaxKind.JsxSelfClosingElement)) { + // Go up until we hit either the element or expression + let jsxNode = contextToken; - if (previousToken !== contextToken) { - Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + while (jsxNode) { + if (jsxNode.kind === SyntaxKind.JsxExpression) { + // Defer to global completion if we're inside an {expression} + break; + } else if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement || jsxNode.kind === SyntaxKind.JsxElement) { + let attrsType: Type; + if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement) { + // Cursor is inside a JSX self-closing element + attrsType = typeChecker.getJsxElementAttributesType(jsxNode); + } + else { + Debug.assert(jsxNode.kind === SyntaxKind.JsxElement); + // Cursor is inside a JSX element + attrsType = typeChecker.getJsxElementAttributesType((jsxNode).openingElement); + } + symbols = typeChecker.getPropertiesOfType(attrsType); + isMemberCompletion = true; + return true; + } + jsxNode = jsxNode.parent; } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - let adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - - let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - - /// TODO filter meaning based on the current context - let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); } + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + + if (previousToken !== contextToken) { + Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + let adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + + let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + + /// TODO filter meaning based on the current context + let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; } @@ -3078,7 +3136,7 @@ namespace ts { * accurately aggregate locals from the closest containing scope. */ function getScopeNode(initialToken: Node, position: number, sourceFile: SourceFile) { - var scope = initialToken; + let scope = initialToken; while (scope && !positionBelongsToNode(scope, position, sourceFile)) { scope = scope.parent; } @@ -3190,17 +3248,18 @@ namespace ts { return false; } - function getContainingObjectLiteralApplicableForCompletion(previousToken: Node): ObjectLiteralExpression { - // The locations in an object literal expression that are applicable for completion are property name definition locations. - - if (previousToken) { - let parent = previousToken.parent; - - switch (previousToken.kind) { + /** + * Returns the immediate owning object literal or binding pattern of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetObjectLikeCompletionContainer(contextToken: Node): ObjectLiteralExpression | BindingPattern { + if (contextToken) { + switch (contextToken.kind) { case SyntaxKind.OpenBraceToken: // let x = { | case SyntaxKind.CommaToken: // let x = { a: 0, | - if (parent && parent.kind === SyntaxKind.ObjectLiteralExpression) { - return parent; + let parent = contextToken.parent; + if (parent && (parent.kind === SyntaxKind.ObjectLiteralExpression || parent.kind === SyntaxKind.ObjectBindingPattern)) { + return parent; } break; } @@ -3239,8 +3298,7 @@ namespace ts { containingNodeKind === SyntaxKind.ClassDeclaration || // class A !lookUp(exisingImports, e.name)); } - function filterContextualMembersList(contextualMemberSymbols: Symbol[], existingMembers: Declaration[]): Symbol[] { + function filterObjectMembersList(contextualMemberSymbols: Symbol[], existingMembers: Declaration[]): Symbol[] { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; } let existingMemberNames: Map = {}; - forEach(existingMembers, m => { - if (m.kind !== SyntaxKind.PropertyAssignment && m.kind !== SyntaxKind.ShorthandPropertyAssignment) { - // Ignore omitted expressions for missing members in the object literal - return; + for (let m of existingMembers) { + // Ignore omitted expressions for missing members + if (m.kind !== SyntaxKind.PropertyAssignment && + m.kind !== SyntaxKind.ShorthandPropertyAssignment && + m.kind !== SyntaxKind.BindingElement) { + continue; } + // If this is the current item we are editing right now, do not filter it out if (m.getStart() <= position && position <= m.getEnd()) { - // If this is the current item we are editing right now, do not filter it out - return; + continue; } - // TODO(jfreeman): Account for computed property name - existingMemberNames[(m.name).text] = true; - }); + let existingName: string; + + if (m.kind === SyntaxKind.BindingElement && (m).propertyName) { + existingName = (m).propertyName.text; + } + else { + // TODO(jfreeman): Account for computed property name + // NOTE: if one only performs this step when m.name is an identifier, + // things like '__proto__' are not filtered out. + existingName = (m.name).text; + } + + existingMemberNames[existingName] = true; + } let filteredMembers: Symbol[] = []; forEach(contextualMemberSymbols, s => { @@ -3467,10 +3537,10 @@ namespace ts { function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] { let start = new Date().getTime(); - var entries: CompletionEntry[] = []; + let entries: CompletionEntry[] = []; if (symbols) { - var nameToSymbol: Map = {}; + let nameToSymbol: Map = {}; for (let symbol of symbols) { let entry = createCompletionEntry(symbol, location); if (entry) { @@ -3504,13 +3574,13 @@ namespace ts { let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined); if (symbol) { - let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); + let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); return { name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation + kind: symbolKind, + displayParts, + documentation }; } } @@ -4185,10 +4255,10 @@ namespace ts { } if (type.flags & TypeFlags.Union) { - var result: DefinitionInfo[] = []; + let result: DefinitionInfo[] = []; forEach((type).types, t => { if (t.symbol) { - result.push(...getDefinitionFromSymbol(t.symbol, node)); + addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -4203,7 +4273,7 @@ namespace ts { function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { let results = getOccurrencesAtPositionCore(fileName, position); - + if (results) { let sourceFile = getCanonicalFileName(normalizeSlashes(fileName)); @@ -4247,7 +4317,7 @@ namespace ts { isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - let referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } @@ -4285,7 +4355,7 @@ namespace ts { function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] { let fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); + let highlightSpans = getHighlightSpans(node); if (!highlightSpans || highlightSpans.length === 0) { return undefined; } @@ -4863,17 +4933,17 @@ namespace ts { } function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + let referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName: string, position: number): ReferencedSymbol[]{ - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return filter(referencedSymbols, rs => !!rs.definition); @@ -4899,10 +4969,10 @@ namespace ts { } Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral); - return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencedSymbolsForNodes(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { let typeChecker = program.getTypeChecker(); // Labels @@ -4937,7 +5007,7 @@ namespace ts { let declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g.undefined symbol + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!declarations || !declarations.length) { return undefined; } @@ -4947,8 +5017,9 @@ namespace ts { // Compute the meaning from the location and the symbol it references let searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for, we need to normalize it as external module names will have quote - let declaredName = getDeclaredName(symbol, node); + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. + let declaredName = getDeclaredName(typeChecker, symbol, node); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -4995,76 +5066,43 @@ namespace ts { }; } - function isImportOrExportSpecifierName(location: Node): boolean { - return location.parent && - (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && - (location.parent).propertyName === location; - } - function isImportOrExportSpecifierImportSymbol(symbol: Symbol) { return (symbol.flags & SymbolFlags.Alias) && forEach(symbol.declarations, declaration => { return declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ExportSpecifier; }); } - function getDeclaredName(symbol: Symbol, location: Node) { - // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(symbol.declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); - - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name: string; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - - name = typeChecker.symbolToString(symbol); - - return stripQuotes(name); - } - function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string { - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. if (isImportOrExportSpecifierName(location)) { return location.getText(); } - // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name = functionExpression && functionExpression.name - ? functionExpression.name.text - : symbol.name; - - return stripQuotes(name); - } - - function stripQuotes(name: string) { - let length = name.length; - if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { - return name.substring(1, length - 1); - }; - return name; + return stripQuotes(symbol.name); } + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ function getSymbolScope(symbol: Symbol): Node { + // If this is the symbol of a function expression, then named references + // are limited to its own scope. + let valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { let privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined); @@ -5172,7 +5210,7 @@ namespace ts { } }); - var definition: DefinitionInfo = { + let definition: DefinitionInfo = { containerKind: "", containerName: "", fileName: targetLabel.getSourceFile().fileName, @@ -5268,10 +5306,10 @@ namespace ts { if (referenceSymbol) { let referenceSymbolDeclaration = referenceSymbol.valueDeclaration; let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + let relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); if (relatedSymbol) { - var referencedSymbol = getReferencedSymbol(relatedSymbol); + let referencedSymbol = getReferencedSymbol(relatedSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); } /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment @@ -5281,7 +5319,7 @@ namespace ts { * position of property accessing, the referenceEntry of such position will be handled in the first case. */ else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + let referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } @@ -5291,8 +5329,8 @@ namespace ts { return; function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { - var symbolId = getSymbolId(symbol); - var index = symbolToIndex[symbolId]; + let symbolId = getSymbolId(symbol); + let index = symbolToIndex[symbolId]; if (index === undefined) { index = result.length; symbolToIndex[symbolId] = index; @@ -5379,7 +5417,7 @@ namespace ts { } }); - var definition = getDefinition(searchSpaceNode.symbol); + let definition = getDefinition(searchSpaceNode.symbol); return [{ definition, references }]; } @@ -5574,7 +5612,7 @@ namespace ts { // If the reference symbol is an alias, check if what it is aliasing is one of the search // symbols. if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { - var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); + let aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; } @@ -5807,11 +5845,12 @@ namespace ts { } function isTypeReference(node: Node): boolean { - if (isRightSideOfQualifiedNameOrPropertyAccess(node) ) { + if (isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === SyntaxKind.TypeReference || node.parent.kind === SyntaxKind.ExpressionWithTypeArguments; + return node.parent.kind === SyntaxKind.TypeReference || + (node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node: Node): boolean { @@ -5975,13 +6014,13 @@ namespace ts { return BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } - function getNavigationBarItems(fileName: string): NavigationBarItem[]{ + function getNavigationBarItems(fileName: string): NavigationBarItem[] { let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); return NavigationBar.getNavigationBarItems(sourceFile); } - function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } @@ -6043,7 +6082,8 @@ namespace ts { */ function hasValueSideModule(symbol: Symbol): boolean { return forEach(symbol.declarations, declaration => { - return declaration.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(declaration) == ModuleInstanceState.Instantiated; + return declaration.kind === SyntaxKind.ModuleDeclaration && + getModuleInstanceState(declaration) === ModuleInstanceState.Instantiated; }); } } @@ -6109,17 +6149,19 @@ namespace ts { return result; } - function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); } function getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications { // doesn't use compiler - no need to synchronize with host let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + let spanStart = span.start; + let spanLength = span.length; // Make a scanner we can get trivia from. - let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); - let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); + let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); let result: number[] = []; processElement(sourceFile); @@ -6132,48 +6174,55 @@ namespace ts { result.push(type); } - function classifyLeadingTrivia(token: Node): void { - let tokenStart = skipTrivia(sourceFile.text, token.pos, /*stopAfterLineBreak:*/ false); - if (tokenStart === token.pos) { - return; - } - - // token has trivia. Classify them appropriately. + function classifyLeadingTriviaAndGetTokenStart(token: Node): number { triviaScanner.setTextPos(token.pos); while (true) { let start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!couldStartTrivia(sourceFile.text, start)) { + return start; + } + let kind = triviaScanner.scan(); let end = triviaScanner.getTextPos(); let width = end - start; // The moment we get something that isn't trivia, then stop processing. if (!isTrivia(kind)) { - return; + return start; + } + + // Don't bother with newlines/whitespace. + if (kind === SyntaxKind.NewLineTrivia || kind === SyntaxKind.WhitespaceTrivia) { + continue; } // Only bother with the trivia if it at least intersects the span of interest. - if (textSpanIntersectsWith(span, start, width)) { - if (isComment(kind)) { - classifyComment(token, kind, start, width); + if (isComment(kind)) { + classifyComment(token, kind, start, width); + + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + + if (kind === SyntaxKind.ConflictMarkerTrivia) { + let text = sourceFile.text; + let ch = text.charCodeAt(start); + + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) { + pushClassification(start, width, ClassificationType.comment); continue; } - if (kind === SyntaxKind.ConflictMarkerTrivia) { - let text = sourceFile.text; - let ch = text.charCodeAt(start); - - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) { - pushClassification(start, width, ClassificationType.comment); - continue; - } - - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - Debug.assert(ch === CharacterCodes.equals); - classifyDisabledMergeCode(text, start, end); - } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + Debug.assert(ch === CharacterCodes.equals); + classifyDisabledMergeCode(text, start, end); } } } @@ -6292,12 +6341,18 @@ namespace ts { } function classifyToken(token: Node): void { - classifyLeadingTrivia(token); + if (nodeIsMissing(token)) { + return; + } - if (token.getWidth() > 0) { + let tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + + let tokenWidth = token.end - tokenStart; + Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { let type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -6402,9 +6457,10 @@ namespace ts { } // Ignore nodes that don't intersect the original span to classify. - if (textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { let children = element.getChildren(sourceFile); - for (let child of children) { + for (let i = 0, n = children.length; i < n; i++) { + let child = children[i]; if (isToken(child)) { classifyToken(child); } @@ -6460,14 +6516,14 @@ namespace ts { function getMatchingTokenKind(token: Node): ts.SyntaxKind { switch (token.kind) { - case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken - case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken; - case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken; - case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken; - case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken - case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken; - case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken; - case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken; + case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken + case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken; + case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken; + case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken; + case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken + case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken; + case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken; + case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken; } return undefined; @@ -6682,18 +6738,20 @@ namespace ts { if (defaultLibFileName) { for (let current of declarations) { let sourceFile = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); if (sourceFile && getCanonicalFileName(ts.normalizePath(sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } } + let displayName = getDeclaredName(typeChecker, symbol, node); let kind = getSymbolKind(symbol, node); if (kind) { return { canRename: true, localizedErrorMessage: undefined, - displayName: symbol.name, + displayName, fullDisplayName: typeChecker.getFullyQualifiedName(symbol), kind: kind, kindModifiers: getSymbolModifiers(symbol), @@ -6872,7 +6930,7 @@ namespace ts { } function convertClassifications(classifications: Classifications, text: string): ClassificationResult { - var entries: ClassificationInfo[] = []; + let entries: ClassificationInfo[] = []; let dense = classifications.spans; let lastEnd = 0; @@ -6910,7 +6968,7 @@ namespace ts { case ClassificationType.stringLiteral: return TokenClass.StringLiteral; case ClassificationType.whiteSpace: return TokenClass.Whitespace; case ClassificationType.punctuation: return TokenClass.Punctuation; - case ClassificationType.identifier: + case ClassificationType.identifier: case ClassificationType.className: case ClassificationType.enumName: case ClassificationType.interfaceName: @@ -6965,7 +7023,7 @@ namespace ts { case EndOfLineState.InTemplateMiddleOrTail: text = "}\n" + text; offset = 2; - // fallthrough + // fallthrough case EndOfLineState.InTemplateSubstitutionPosition: templateStack.push(SyntaxKind.TemplateHead); break; @@ -7004,9 +7062,9 @@ namespace ts { if (!isTrivia(token)) { if ((token === SyntaxKind.SlashToken || token === SyntaxKind.SlashEqualsToken) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { - token = SyntaxKind.RegularExpressionLiteral; - } + if (scanner.reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { + token = SyntaxKind.RegularExpressionLiteral; + } } else if (lastNonTriviaToken === SyntaxKind.DotToken && isKeyword(token)) { token = SyntaxKind.Identifier; @@ -7019,7 +7077,7 @@ namespace ts { token = SyntaxKind.Identifier; } else if (lastNonTriviaToken === SyntaxKind.Identifier && - token === SyntaxKind.LessThanToken) { + token === SyntaxKind.LessThanToken) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; @@ -7030,10 +7088,10 @@ namespace ts { angleBracketStack--; } else if (token === SyntaxKind.AnyKeyword || - token === SyntaxKind.StringKeyword || - token === SyntaxKind.NumberKeyword || - token === SyntaxKind.BooleanKeyword || - token === SyntaxKind.SymbolKeyword) { + token === SyntaxKind.StringKeyword || + token === SyntaxKind.NumberKeyword || + token === SyntaxKind.BooleanKeyword || + token === SyntaxKind.SymbolKeyword) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -7269,7 +7327,7 @@ namespace ts { declare let __dirname: string; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ diff --git a/src/services/shims.ts b/src/services/shims.ts index 9a586a1ec12..2e8b3eb774d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -234,6 +234,7 @@ namespace ts { public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + // TODO: should this be '==='? if (encoded == null) { return null; } @@ -283,6 +284,7 @@ namespace ts { public getCompilationSettings(): CompilerOptions { var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 73b88a3df26..0fd945caa7d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -652,4 +652,34 @@ namespace ts { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); } + + export function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + + let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + + return stripQuotes(name); + } + + export function isImportOrExportSpecifierName(location: Node): boolean { + return location.parent && + (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && + (location.parent).propertyName === location; + } + + export function stripQuotes(name: string) { + let length = name.length; + if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { + return name.substring(1, length - 1); + }; + return name; + } } \ No newline at end of file diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 380212988d3..fd7be9fc2a5 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,28 +75,28 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 192 /* ForStatement */: - case 193 /* ForInStatement */: - case 191 /* WhileStatement */: - case 190 /* DoStatement */: - if (node.statement.kind !== 185 /* Block */) { + case 194 /* ForStatement */: + case 195 /* ForInStatement */: + case 193 /* WhileStatement */: + case 192 /* DoStatement */: + if (node.statement.kind !== 187 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 189 /* IfStatement */: + case 191 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 185 /* Block */) { + if (ifStatement.thenStatement.kind !== 187 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 185 /* Block */ && - ifStatement.elseStatement.kind !== 189 /* IfStatement */) { + ifStatement.elseStatement.kind !== 187 /* Block */ && + ifStatement.elseStatement.kind !== 191 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 175 /* BinaryExpression */: + case 176 /* BinaryExpression */: var op = node.operatorToken.kind; - if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { + if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); } break; diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index ec30d5b4dc7..3e48462062d 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -24,8 +24,7 @@ module A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A; (function (A) { diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js index 4d296bf9ea5..a1386033e9f 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js @@ -28,8 +28,7 @@ module A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A; (function (A) { diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.js b/tests/baselines/reference/accessOverriddenBaseClassMember1.js index f6d3f29f1ab..e3a4d0602b8 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.js +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.js @@ -19,8 +19,7 @@ class ColoredPoint extends Point { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Point = (function () { function Point(x, y) { diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.js b/tests/baselines/reference/accessors_spec_section-4.5_inference.js index 8b75e27031a..808019448b7 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_inference.js +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -28,8 +28,7 @@ class LanguageSpec_section_4_5_inference { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js index 06c8b55e23d..11e02297e47 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js @@ -38,8 +38,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsage1_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.types b/tests/baselines/reference/aliasUsageInAccessorsOfClass.types index eccdbc8528c..092643002e4 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.types +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.types @@ -53,9 +53,9 @@ import Backbone = require("aliasUsage1_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index e5d44320c7d..ba0c954a3c2 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -32,8 +32,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInArray_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInArray.types b/tests/baselines/reference/aliasUsageInArray.types index ee54300e7d9..488cc97d07f 100644 --- a/tests/baselines/reference/aliasUsageInArray.types +++ b/tests/baselines/reference/aliasUsageInArray.types @@ -41,9 +41,9 @@ import Backbone = require("aliasUsageInArray_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.js b/tests/baselines/reference/aliasUsageInFunctionExpression.js index b7b95661ac8..702cbe4d53f 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.js +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.js @@ -31,8 +31,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInFunctionExpression_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.types b/tests/baselines/reference/aliasUsageInFunctionExpression.types index 17994dcab52..eec4341fd67 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.types +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.types @@ -42,9 +42,9 @@ import Backbone = require("aliasUsageInFunctionExpression_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index 856e6ddb43e..8706dd592eb 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -35,8 +35,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInGenericFunction_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.types b/tests/baselines/reference/aliasUsageInGenericFunction.types index 0821732f5fc..c21e691d773 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.types +++ b/tests/baselines/reference/aliasUsageInGenericFunction.types @@ -57,9 +57,9 @@ import Backbone = require("aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index e05f5e4f5cd..78ddd2d4a94 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -37,8 +37,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInIndexerOfClass_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.types b/tests/baselines/reference/aliasUsageInIndexerOfClass.types index fe67655d4f5..b7e4873ba34 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.types +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.types @@ -50,9 +50,9 @@ import Backbone = require("aliasUsageInIndexerOfClass_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index cc4b8273e84..f38cdf2111c 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -32,8 +32,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInObjectLiteral_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.types b/tests/baselines/reference/aliasUsageInObjectLiteral.types index 32a78d555b1..5ab294b7350 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.types +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.types @@ -55,9 +55,9 @@ import Backbone = require("aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index f382ee2f617..906a2c019d7 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -35,8 +35,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInOrExpression_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInOrExpression.types b/tests/baselines/reference/aliasUsageInOrExpression.types index 8d3163d481b..e7ca8639762 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.types +++ b/tests/baselines/reference/aliasUsageInOrExpression.types @@ -79,9 +79,9 @@ import Backbone = require("aliasUsageInOrExpression_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index 39ff58a5322..27f85bb5fcd 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -35,8 +35,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); var VisualizationModel = (function (_super) { @@ -51,8 +50,7 @@ exports.VisualizationModel = VisualizationModel; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); var C = (function () { diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types index 460b422a2a4..ae20caa9c37 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types @@ -25,7 +25,7 @@ class C { } class D extends C { >D : D ->C : C +>C : C >IHasVisualizationModel : IHasVisualizationModel x = moduleA; @@ -46,9 +46,9 @@ import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index 2de34f00566..bfc63868ff4 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -31,8 +31,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("aliasUsageInVarAssignment_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.types b/tests/baselines/reference/aliasUsageInVarAssignment.types index b5d20a1b372..6a23293ea7c 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.types +++ b/tests/baselines/reference/aliasUsageInVarAssignment.types @@ -37,9 +37,9 @@ import Backbone = require("aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/ambiguousOverloadResolution.js b/tests/baselines/reference/ambiguousOverloadResolution.js index 8c2ceb055c7..23c985d2f8d 100644 --- a/tests/baselines/reference/ambiguousOverloadResolution.js +++ b/tests/baselines/reference/ambiguousOverloadResolution.js @@ -12,8 +12,7 @@ var t: number = f(x, x); // Not an error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/anonymousClassExpression1.errors.txt b/tests/baselines/reference/anonymousClassExpression1.errors.txt deleted file mode 100644 index db4c5b4ce3d..00000000000 --- a/tests/baselines/reference/anonymousClassExpression1.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/anonymousClassExpression1.ts(2,19): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/compiler/anonymousClassExpression1.ts (1 errors) ==== - function f() { - return typeof class {} === "function"; - ~~~~~ -!!! error TS9003: 'class' expressions are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/anonymousClassExpression1.js b/tests/baselines/reference/anonymousClassExpression1.js index 78cf5b05c51..5ced5120979 100644 --- a/tests/baselines/reference/anonymousClassExpression1.js +++ b/tests/baselines/reference/anonymousClassExpression1.js @@ -6,8 +6,8 @@ function f() { //// [anonymousClassExpression1.js] function f() { return typeof (function () { - function default_1() { + function class_1() { } - return default_1; + return class_1; })() === "function"; } diff --git a/tests/baselines/reference/anonymousClassExpression1.symbols b/tests/baselines/reference/anonymousClassExpression1.symbols new file mode 100644 index 00000000000..114bfc96097 --- /dev/null +++ b/tests/baselines/reference/anonymousClassExpression1.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/anonymousClassExpression1.ts === +function f() { +>f : Symbol(f, Decl(anonymousClassExpression1.ts, 0, 0)) + + return typeof class {} === "function"; +} diff --git a/tests/baselines/reference/anonymousClassExpression1.types b/tests/baselines/reference/anonymousClassExpression1.types new file mode 100644 index 00000000000..1e38399f01e --- /dev/null +++ b/tests/baselines/reference/anonymousClassExpression1.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/anonymousClassExpression1.ts === +function f() { +>f : () => boolean + + return typeof class {} === "function"; +>typeof class {} === "function" : boolean +>typeof class {} : string +>class {} : typeof (Anonymous class) +>"function" : string +} diff --git a/tests/baselines/reference/apparentTypeSubtyping.js b/tests/baselines/reference/apparentTypeSubtyping.js index 087a91fb02c..edc0f21323a 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.js +++ b/tests/baselines/reference/apparentTypeSubtyping.js @@ -27,8 +27,7 @@ class Derived2 extends Base2 { // error because of the prototy var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/apparentTypeSupertype.js b/tests/baselines/reference/apparentTypeSupertype.js index 0b4462bebe7..2ab84c89513 100644 --- a/tests/baselines/reference/apparentTypeSupertype.js +++ b/tests/baselines/reference/apparentTypeSupertype.js @@ -17,8 +17,7 @@ class Derived extends Base { // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/arrayAssignmentTest1.js b/tests/baselines/reference/arrayAssignmentTest1.js index 43aad9921bb..70177b4cba2 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.js +++ b/tests/baselines/reference/arrayAssignmentTest1.js @@ -89,8 +89,7 @@ arr_any = i1; // should be an error - is var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/arrayAssignmentTest2.js b/tests/baselines/reference/arrayAssignmentTest2.js index 5aeb74114bc..61bddd7e8e4 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.js +++ b/tests/baselines/reference/arrayAssignmentTest2.js @@ -63,8 +63,7 @@ arr_any = i1; // should be an error - is var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index 8d2445e2739..95dd299ad43 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -111,8 +111,7 @@ module NonEmptyTypes { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var EmptyTypes; (function (EmptyTypes) { diff --git a/tests/baselines/reference/arrayLiteralTypeInference.js b/tests/baselines/reference/arrayLiteralTypeInference.js index dfd662bbf1c..fc573aa390e 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.js +++ b/tests/baselines/reference/arrayLiteralTypeInference.js @@ -55,8 +55,7 @@ var z3: { id: number }[] = var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Action = (function () { function Action() { diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index cb1d25258f2..0f86b7a7f2a 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -41,8 +41,7 @@ var context4: Base[] = [new Derived1(), new Derived1()]; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var arr1 = [[], [1], ['']]; var arr2 = [[null], [1], ['']]; diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js index b3c0a0f7877..e303415df08 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js @@ -29,8 +29,7 @@ var as = [list, myDerivedList]; // List[] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var List = (function () { function List() { diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index 9b2abf25c2d..9cdbe0a0a61 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -17,7 +17,7 @@ class List { class DerivedList extends List { >DerivedList : DerivedList >U : U ->List : List +>List : List >U : U foo: U; diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index f4a11fb47ae..5d862dcec8c 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -100,8 +100,7 @@ var asserted2: any; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Arrow function used in with statement with (window) { diff --git a/tests/baselines/reference/asOperator1.js b/tests/baselines/reference/asOperator1.js new file mode 100644 index 00000000000..1b23d0a86f7 --- /dev/null +++ b/tests/baselines/reference/asOperator1.js @@ -0,0 +1,19 @@ +//// [asOperator1.ts] +var as = 43; +var x = undefined as number; +var y = (null as string).length; +var z = Date as any as string; + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +j = ''; + + +//// [asOperator1.js] +var as = 43; +var x = undefined; +var y = null.length; +var z = Date; +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32; +j = ''; diff --git a/tests/baselines/reference/asOperator1.symbols b/tests/baselines/reference/asOperator1.symbols new file mode 100644 index 00000000000..27353ec7b30 --- /dev/null +++ b/tests/baselines/reference/asOperator1.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator1.ts === +var as = 43; +>as : Symbol(as, Decl(asOperator1.ts, 0, 3)) + +var x = undefined as number; +>x : Symbol(x, Decl(asOperator1.ts, 1, 3)) +>undefined : Symbol(undefined) + +var y = (null as string).length; +>y : Symbol(y, Decl(asOperator1.ts, 2, 3)) +>(null as string).length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + +var z = Date as any as string; +>z : Symbol(z, Decl(asOperator1.ts, 3, 3)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +>j : Symbol(j, Decl(asOperator1.ts, 6, 3)) + +j = ''; +>j : Symbol(j, Decl(asOperator1.ts, 6, 3)) + diff --git a/tests/baselines/reference/asOperator1.types b/tests/baselines/reference/asOperator1.types new file mode 100644 index 00000000000..3f69871ea09 --- /dev/null +++ b/tests/baselines/reference/asOperator1.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator1.ts === +var as = 43; +>as : number +>43 : number + +var x = undefined as number; +>x : number +>undefined as number : number +>undefined : undefined + +var y = (null as string).length; +>y : number +>(null as string).length : number +>(null as string) : string +>null as string : string +>null : null +>length : number + +var z = Date as any as string; +>z : string +>Date as any as string : string +>Date as any : any +>Date : DateConstructor + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +>j : string | number +>32 as number|string : string | number +>32 : number + +j = ''; +>j = '' : string +>j : string | number +>'' : string + diff --git a/tests/baselines/reference/asOperator2.errors.txt b/tests/baselines/reference/asOperator2.errors.txt new file mode 100644 index 00000000000..3b074038c26 --- /dev/null +++ b/tests/baselines/reference/asOperator2.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/expressions/asOperator/asOperator2.ts(1,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + + +==== tests/cases/conformance/expressions/asOperator/asOperator2.ts (1 errors) ==== + var x = 23 as string; + ~~~~~~~~~~~~ +!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + \ No newline at end of file diff --git a/tests/baselines/reference/asOperator2.js b/tests/baselines/reference/asOperator2.js new file mode 100644 index 00000000000..32962555d51 --- /dev/null +++ b/tests/baselines/reference/asOperator2.js @@ -0,0 +1,6 @@ +//// [asOperator2.ts] +var x = 23 as string; + + +//// [asOperator2.js] +var x = 23; diff --git a/tests/baselines/reference/asOperator3.js b/tests/baselines/reference/asOperator3.js new file mode 100644 index 00000000000..406eae1c9d6 --- /dev/null +++ b/tests/baselines/reference/asOperator3.js @@ -0,0 +1,22 @@ +//// [asOperator3.ts] +declare function tag(...x: any[]): any; + +var a = `${123 + 456 as number}`; +var b = `leading ${123 + 456 as number}`; +var c = `${123 + 456 as number} trailing`; +var d = `Hello ${123} World` as string; +var e = `Hello` as string; +var f = 1 + `${1} end of string` as string; +var g = tag `Hello ${123} World` as string; +var h = tag `Hello` as string; + +//// [asOperator3.js] +var a = "" + 123 + 456; +var b = "leading " + 123 + 456; +var c = 123 + 456 + " trailing"; +var d = ("Hello " + 123 + " World"); +var e = "Hello"; +var f = 1 + (1 + " end of string"); +var g = (_a = ["Hello ", " World"], _a.raw = ["Hello ", " World"], tag(_a, 123)); +var h = (_b = ["Hello"], _b.raw = ["Hello"], tag(_b)); +var _a, _b; diff --git a/tests/baselines/reference/asOperator3.symbols b/tests/baselines/reference/asOperator3.symbols new file mode 100644 index 00000000000..d29a64d3c3a --- /dev/null +++ b/tests/baselines/reference/asOperator3.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator3.ts === +declare function tag(...x: any[]): any; +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) +>x : Symbol(x, Decl(asOperator3.ts, 0, 21)) + +var a = `${123 + 456 as number}`; +>a : Symbol(a, Decl(asOperator3.ts, 2, 3)) + +var b = `leading ${123 + 456 as number}`; +>b : Symbol(b, Decl(asOperator3.ts, 3, 3)) + +var c = `${123 + 456 as number} trailing`; +>c : Symbol(c, Decl(asOperator3.ts, 4, 3)) + +var d = `Hello ${123} World` as string; +>d : Symbol(d, Decl(asOperator3.ts, 5, 3)) + +var e = `Hello` as string; +>e : Symbol(e, Decl(asOperator3.ts, 6, 3)) + +var f = 1 + `${1} end of string` as string; +>f : Symbol(f, Decl(asOperator3.ts, 7, 3)) + +var g = tag `Hello ${123} World` as string; +>g : Symbol(g, Decl(asOperator3.ts, 8, 3)) +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) + +var h = tag `Hello` as string; +>h : Symbol(h, Decl(asOperator3.ts, 9, 3)) +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) + diff --git a/tests/baselines/reference/asOperator3.types b/tests/baselines/reference/asOperator3.types new file mode 100644 index 00000000000..507dfd8b572 --- /dev/null +++ b/tests/baselines/reference/asOperator3.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator3.ts === +declare function tag(...x: any[]): any; +>tag : (...x: any[]) => any +>x : any[] + +var a = `${123 + 456 as number}`; +>a : string +>`${123 + 456 as number}` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var b = `leading ${123 + 456 as number}`; +>b : string +>`leading ${123 + 456 as number}` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var c = `${123 + 456 as number} trailing`; +>c : string +>`${123 + 456 as number} trailing` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var d = `Hello ${123} World` as string; +>d : string +>`Hello ${123} World` as string : string +>`Hello ${123} World` : string +>123 : number + +var e = `Hello` as string; +>e : string +>`Hello` as string : string +>`Hello` : string + +var f = 1 + `${1} end of string` as string; +>f : string +>1 + `${1} end of string` as string : string +>1 + `${1} end of string` : string +>1 : number +>`${1} end of string` : string +>1 : number + +var g = tag `Hello ${123} World` as string; +>g : string +>tag `Hello ${123} World` as string : string +>tag `Hello ${123} World` : any +>tag : (...x: any[]) => any +>`Hello ${123} World` : string +>123 : number + +var h = tag `Hello` as string; +>h : string +>tag `Hello` as string : string +>tag `Hello` : any +>tag : (...x: any[]) => any +>`Hello` : string + diff --git a/tests/baselines/reference/asOperatorASI.js b/tests/baselines/reference/asOperatorASI.js new file mode 100644 index 00000000000..1df39b36e50 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.js @@ -0,0 +1,26 @@ +//// [asOperatorASI.ts] +class Foo { } +declare function as(...args: any[]); + +// Example 1 +var x = 10 +as `Hello world`; // should not error + +// Example 2 +var y = 20 +as(Foo); // should emit + + +//// [asOperatorASI.js] +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +// Example 1 +var x = 10; +(_a = ["Hello world"], _a.raw = ["Hello world"], as(_a)); // should not error +// Example 2 +var y = 20; +as(Foo); // should emit +var _a; diff --git a/tests/baselines/reference/asOperatorASI.symbols b/tests/baselines/reference/asOperatorASI.symbols new file mode 100644 index 00000000000..7def6d460c1 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts === +class Foo { } +>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0)) + +declare function as(...args: any[]); +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) +>args : Symbol(args, Decl(asOperatorASI.ts, 1, 20)) + +// Example 1 +var x = 10 +>x : Symbol(x, Decl(asOperatorASI.ts, 4, 3)) + +as `Hello world`; // should not error +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) + +// Example 2 +var y = 20 +>y : Symbol(y, Decl(asOperatorASI.ts, 8, 3)) + +as(Foo); // should emit +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) +>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0)) + diff --git a/tests/baselines/reference/asOperatorASI.types b/tests/baselines/reference/asOperatorASI.types new file mode 100644 index 00000000000..61c2d115cf4 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts === +class Foo { } +>Foo : Foo + +declare function as(...args: any[]); +>as : (...args: any[]) => any +>args : any[] + +// Example 1 +var x = 10 +>x : number +>10 : number + +as `Hello world`; // should not error +>as `Hello world` : any +>as : (...args: any[]) => any +>`Hello world` : string + +// Example 2 +var y = 20 +>y : number +>20 : number + +as(Foo); // should emit +>as(Foo) : any +>as : (...args: any[]) => any +>Foo : typeof Foo + diff --git a/tests/baselines/reference/asOperatorAmbiguity.errors.txt b/tests/baselines/reference/asOperatorAmbiguity.errors.txt new file mode 100644 index 00000000000..cb7c6d4132c --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts(7,14): error TS2339: Property 'm' does not exist on type 'A'. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts (1 errors) ==== + interface A { x: T; } + interface B { m: string; } + + // Make sure this is a type assertion to an array type, and not nested comparison operators. + var x: any; + var y = x as A[]; + var z = y[0].m; // z should be string + ~ +!!! error TS2339: Property 'm' does not exist on type 'A'. + + \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorAmbiguity.js b/tests/baselines/reference/asOperatorAmbiguity.js new file mode 100644 index 00000000000..6c336970b65 --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.js @@ -0,0 +1,16 @@ +//// [asOperatorAmbiguity.ts] +interface A { x: T; } +interface B { m: string; } + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +var y = x as A[]; +var z = y[0].m; // z should be string + + + +//// [asOperatorAmbiguity.js] +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x; +var y = x; +var z = y[0].m; // z should be string diff --git a/tests/baselines/reference/asOperatorContextualType.errors.txt b/tests/baselines/reference/asOperatorContextualType.errors.txt new file mode 100644 index 00000000000..c53b407b5cf --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts (1 errors) ==== + // should error + var x = (v => v) as (x: number) => string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other. +!!! error TS2352: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorContextualType.js b/tests/baselines/reference/asOperatorContextualType.js new file mode 100644 index 00000000000..7b495ada8f4 --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.js @@ -0,0 +1,7 @@ +//// [asOperatorContextualType.ts] +// should error +var x = (v => v) as (x: number) => string; + +//// [asOperatorContextualType.js] +// should error +var x = (function (v) { return v; }); diff --git a/tests/baselines/reference/asOperatorNames.errors.txt b/tests/baselines/reference/asOperatorNames.errors.txt new file mode 100644 index 00000000000..e3dfaab9884 --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/expressions/asOperator/asOperatorNames.ts(2,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorNames.ts (1 errors) ==== + var a = 20; + var b = a as string; + ~~~~~~~~~~~ +!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + var as = "hello"; + var as1 = as as string; + \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorNames.js b/tests/baselines/reference/asOperatorNames.js new file mode 100644 index 00000000000..35e80d080e3 --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.js @@ -0,0 +1,12 @@ +//// [asOperatorNames.ts] +var a = 20; +var b = a as string; +var as = "hello"; +var as1 = as as string; + + +//// [asOperatorNames.js] +var a = 20; +var b = a; +var as = "hello"; +var as1 = as; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js index 1ad82ca531b..6f2eaf4d5cc 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js @@ -104,8 +104,7 @@ b18 = a18; // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js index 387395525ad..fc6ca05ad30 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js @@ -103,8 +103,7 @@ module Errors { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Errors; (function (Errors) { diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js index 2e3790cd529..ddf16c23f48 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js @@ -70,8 +70,7 @@ b18 = a18; // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js index a29a607f9ef..e57a5ac07a0 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js @@ -47,8 +47,7 @@ b16 = x.a16; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js index 32176e764e9..d02c635c584 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js @@ -104,8 +104,7 @@ b18 = a18; // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js index 21bace1645c..6f9f20333f2 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js @@ -103,8 +103,7 @@ module Errors { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Errors; (function (Errors) { diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js index 76be317e95a..bd4c73e65dd 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js @@ -70,8 +70,7 @@ b18 = a18; // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js index dc1d0dd2dee..98477fa1523 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js @@ -47,8 +47,7 @@ b16 = x.a16; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js index 6044c40b3cc..617d136bbb2 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js @@ -48,8 +48,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js index b3c073ea0b7..0c5b0be038f 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js @@ -45,8 +45,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js index 229525a91f0..20279fb1dc5 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js @@ -96,8 +96,7 @@ module WithBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var OnlyDerived; (function (OnlyDerived) { diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js index 629f7bf5113..6675fab6d69 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js @@ -93,8 +93,7 @@ module SourceHasOptional { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index 4ffec4aa7dd..b89106eba2b 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -95,8 +95,7 @@ module SourceHasOptional { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.js b/tests/baselines/reference/assignmentCompatWithStringIndexer.js index 99457453af4..3391ac5773a 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.js @@ -58,8 +58,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/assignmentLHSIsValue.js b/tests/baselines/reference/assignmentLHSIsValue.js index 33054009d8e..127f85512ac 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.js +++ b/tests/baselines/reference/assignmentLHSIsValue.js @@ -74,8 +74,7 @@ foo() = value; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // expected error for all the LHS of assignments var value; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index 81712c324c0..cb2c5255486 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) }; diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols index 6cd18e254ba..8d4b98a20a1 100644 --- a/tests/baselines/reference/asyncAwait_es6.symbols +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index 339108848fa..889614387d7 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index a9679f38692..626b820e312 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index ce3b922cae8..c71592c0463 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) } diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 5986ef4a3f5..f4bbad50c60 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -27,8 +27,7 @@ class Point3D extends Point { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Point = (function () { function Point(x, y) { diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index ea5174c2035..6a72f1b1506 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = await p || a; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index 6b12c72bce4..f81a146f943 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = await p && a; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index c4e568a54e9..479b3b30650 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,11 +4,11 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = await p + a; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index 77c80010b64..5d15c754793 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = await p, a; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index 451311947aa..bc1e2f19310 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var o: { a: boolean; }; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index 5d44f790f23..7e28d92cd9c 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index fdd6975f45b..305a4c77aa3 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 17ba0bf92c7..715c125bcf0 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index 5bff8aa3b2e..98a995d8117 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = (await pfn)(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index a5a88378074..30df9c8d022 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index ed6f52a4a50..ac1cca1c16f 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = o.fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index 3e901f6dd1b..b48e99ddec1 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = o.fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index fda2b254b17..4dd9d500347 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) "before"; var b = (await po).fn(a, a, a); diff --git a/tests/baselines/reference/baseCheck.js b/tests/baselines/reference/baseCheck.js index 4e7db8e6a5b..49038f37b18 100644 --- a/tests/baselines/reference/baseCheck.js +++ b/tests/baselines/reference/baseCheck.js @@ -33,8 +33,7 @@ function f() { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C(x, y) { diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 85b76221e3c..8463ed58a53 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -28,8 +28,7 @@ var z: Derived = b.foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/baseTypeOrderChecking.js b/tests/baselines/reference/baseTypeOrderChecking.js index 754d90e21ea..4c5fe22ea08 100644 --- a/tests/baselines/reference/baseTypeOrderChecking.js +++ b/tests/baselines/reference/baseTypeOrderChecking.js @@ -40,8 +40,7 @@ class Class4 extends Class3 var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var someVariable; var Class1 = (function () { diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js index aaa93710339..1de1ebd4bfb 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -30,8 +30,7 @@ class Wrapper { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types index 61919bad212..747b672dd0d 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types @@ -2,7 +2,7 @@ class C extends CBase { >C : C >T1 : T1 ->CBase : CBase +>CBase : CBase >T1 : T1 public works() { @@ -35,7 +35,7 @@ class C extends CBase { class CBase extends CBaseBase> { >CBase : CBase >T2 : T2 ->CBaseBase : CBaseBase +>CBaseBase : CBaseBase> >Wrapper : Wrapper >T2 : T2 diff --git a/tests/baselines/reference/bases.js b/tests/baselines/reference/bases.js index 5687e9e0fe1..0275c225dac 100644 --- a/tests/baselines/reference/bases.js +++ b/tests/baselines/reference/bases.js @@ -24,8 +24,7 @@ new C().y; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B() { diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js index e56e530ad64..abd2cc5e874 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js @@ -32,8 +32,7 @@ function foo5(t: T, u: U): Object { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a; var b; diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js index fb3c15a8fba..e0e7bc3f324 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js @@ -30,8 +30,7 @@ function foo3(t: T, u: U) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.js b/tests/baselines/reference/bestCommonTypeOfTuple2.js index 5642df5570c..ed0b0ecb328 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.js @@ -26,8 +26,7 @@ var e51 = t5[2]; // {} var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 685e33acb6b..e43c22fab75 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -74,8 +74,7 @@ interface I extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js index 135c0c056ae..6105ddf23fa 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js @@ -119,8 +119,7 @@ module Errors { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Errors; (function (Errors) { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js index c578a49ee55..aee3af6f740 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js @@ -54,8 +54,7 @@ interface I extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index 74987308ef7..c72a77e4020 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -54,8 +54,7 @@ interface I extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js index aa2e9787bd1..e22bb1189ed 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js @@ -57,8 +57,7 @@ interface I9 extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index d21b4879daa..50840abfbb7 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -54,8 +54,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function foo(x, y) { var z = []; diff --git a/tests/baselines/reference/captureThisInSuperCall.js b/tests/baselines/reference/captureThisInSuperCall.js index 27c80e2991d..611ad93f531 100644 --- a/tests/baselines/reference/captureThisInSuperCall.js +++ b/tests/baselines/reference/captureThisInSuperCall.js @@ -12,8 +12,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(p) { diff --git a/tests/baselines/reference/castingTuple.js b/tests/baselines/reference/castingTuple.js index 8b1005d4487..0102d1310a3 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -36,8 +36,7 @@ t4[2] = 10; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/chainedAssignment3.js b/tests/baselines/reference/chainedAssignment3.js index 022668ba7cf..04c328031cd 100644 --- a/tests/baselines/reference/chainedAssignment3.js +++ b/tests/baselines/reference/chainedAssignment3.js @@ -26,8 +26,7 @@ a = b = new A(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js index 494f0bc1b5d..e7e1a3a871b 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js @@ -23,8 +23,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Chain = (function () { function Chain(value) { diff --git a/tests/baselines/reference/checkForObjectTooStrict.errors.txt b/tests/baselines/reference/checkForObjectTooStrict.errors.txt deleted file mode 100644 index 7af7481f6ae..00000000000 --- a/tests/baselines/reference/checkForObjectTooStrict.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/compiler/checkForObjectTooStrict.ts(22,19): error TS2311: A class may only extend another class. -tests/cases/compiler/checkForObjectTooStrict.ts(26,9): error TS2335: 'super' can only be referenced in a derived class. - - -==== tests/cases/compiler/checkForObjectTooStrict.ts (2 errors) ==== - module Foo { - - export class Object { - - } - - } - - - - class Bar extends Foo.Object { // should work - - constructor () { - - super(); - - } - - } - - - class Baz extends Object { - ~~~~~~ -!!! error TS2311: A class may only extend another class. - - constructor () { // ERROR, as expected - - super(); - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. - - } - - } - \ No newline at end of file diff --git a/tests/baselines/reference/checkForObjectTooStrict.js b/tests/baselines/reference/checkForObjectTooStrict.js index bcdde6b3be1..d8f40a3f1d9 100644 --- a/tests/baselines/reference/checkForObjectTooStrict.js +++ b/tests/baselines/reference/checkForObjectTooStrict.js @@ -35,8 +35,7 @@ class Baz extends Object { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo; (function (Foo) { diff --git a/tests/baselines/reference/checkForObjectTooStrict.symbols b/tests/baselines/reference/checkForObjectTooStrict.symbols new file mode 100644 index 00000000000..48e04392c3b --- /dev/null +++ b/tests/baselines/reference/checkForObjectTooStrict.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/checkForObjectTooStrict.ts === +module Foo { +>Foo : Symbol(Foo, Decl(checkForObjectTooStrict.ts, 0, 0)) + + export class Object { +>Object : Symbol(Object, Decl(checkForObjectTooStrict.ts, 0, 12)) + + } + +} + + + +class Bar extends Foo.Object { // should work +>Bar : Symbol(Bar, Decl(checkForObjectTooStrict.ts, 6, 1)) +>Foo.Object : Symbol(Foo.Object, Decl(checkForObjectTooStrict.ts, 0, 12)) +>Foo : Symbol(Foo, Decl(checkForObjectTooStrict.ts, 0, 0)) +>Object : Symbol(Foo.Object, Decl(checkForObjectTooStrict.ts, 0, 12)) + + constructor () { + + super(); +>super : Symbol(Foo.Object, Decl(checkForObjectTooStrict.ts, 0, 12)) + + } + +} + + +class Baz extends Object { +>Baz : Symbol(Baz, Decl(checkForObjectTooStrict.ts, 18, 1)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) + + constructor () { // ERROR, as expected + + super(); +>super : Symbol(ObjectConstructor, Decl(lib.d.ts, 124, 1)) + + } + +} + diff --git a/tests/baselines/reference/checkForObjectTooStrict.types b/tests/baselines/reference/checkForObjectTooStrict.types new file mode 100644 index 00000000000..f6b63019cd5 --- /dev/null +++ b/tests/baselines/reference/checkForObjectTooStrict.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/checkForObjectTooStrict.ts === +module Foo { +>Foo : typeof Foo + + export class Object { +>Object : Object + + } + +} + + + +class Bar extends Foo.Object { // should work +>Bar : Bar +>Foo.Object : Foo.Object +>Foo : typeof Foo +>Object : typeof Foo.Object + + constructor () { + + super(); +>super() : void +>super : typeof Foo.Object + + } + +} + + +class Baz extends Object { +>Baz : Baz +>Object : Object + + constructor () { // ERROR, as expected + + super(); +>super() : void +>super : ObjectConstructor + + } + +} + diff --git a/tests/baselines/reference/circularImportAlias.js b/tests/baselines/reference/circularImportAlias.js index 1a50a46221b..8b908a97ee6 100644 --- a/tests/baselines/reference/circularImportAlias.js +++ b/tests/baselines/reference/circularImportAlias.js @@ -24,8 +24,7 @@ var c = new B.a.C(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B; (function (B) { diff --git a/tests/baselines/reference/circularImportAlias.types b/tests/baselines/reference/circularImportAlias.types index 3ab41f6187b..e4b2f27dbbe 100644 --- a/tests/baselines/reference/circularImportAlias.types +++ b/tests/baselines/reference/circularImportAlias.types @@ -10,9 +10,9 @@ module B { export class D extends a.C { >D : D ->a.C : any +>a.C : a.C >a : typeof a ->C : a.C +>C : typeof a.C id: number; >id : number diff --git a/tests/baselines/reference/classConstructorParametersAccessibility.js b/tests/baselines/reference/classConstructorParametersAccessibility.js index 5d715556ec1..a5538b66ecc 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility.js @@ -30,8 +30,7 @@ class Derived extends C3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1(x) { diff --git a/tests/baselines/reference/classConstructorParametersAccessibility2.js b/tests/baselines/reference/classConstructorParametersAccessibility2.js index 1d273e119ec..581746a180b 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility2.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility2.js @@ -30,8 +30,7 @@ class Derived extends C3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1(x) { diff --git a/tests/baselines/reference/classConstructorParametersAccessibility3.js b/tests/baselines/reference/classConstructorParametersAccessibility3.js index 43823bbb4d9..d98b094ccdb 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility3.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility3.js @@ -17,8 +17,7 @@ d.p; // public, OK var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(p) { diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js index 7299b04720f..a8d6fcd88e0 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js @@ -15,8 +15,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types index f1be8e6d268..11fcac506b6 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types @@ -19,8 +19,8 @@ module M { export class O extends M.N { >O : O ->M.N : any +>M.N : N >M : typeof M ->N : N +>N : typeof N } } diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js index 52474582315..8515e1d98eb 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js @@ -16,8 +16,7 @@ class StringTreeCollection extends StringTreeCollectionBase { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x; if (typeof x !== "string") { diff --git a/tests/baselines/reference/classExpression.errors.txt b/tests/baselines/reference/classExpression.errors.txt deleted file mode 100644 index c8266d0e879..00000000000 --- a/tests/baselines/reference/classExpression.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -tests/cases/conformance/classes/classExpression.ts(1,15): error TS9003: 'class' expressions are not currently supported. -tests/cases/conformance/classes/classExpression.ts(5,16): error TS9003: 'class' expressions are not currently supported. -tests/cases/conformance/classes/classExpression.ts(10,19): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/conformance/classes/classExpression.ts (3 errors) ==== - var x = class C { - ~ -!!! error TS9003: 'class' expressions are not currently supported. - } - - var y = { - foo: class C2 { - ~~ -!!! error TS9003: 'class' expressions are not currently supported. - } - } - - module M { - var z = class C4 { - ~~ -!!! error TS9003: 'class' expressions are not currently supported. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/classExpression.symbols b/tests/baselines/reference/classExpression.symbols new file mode 100644 index 00000000000..f4d44236499 --- /dev/null +++ b/tests/baselines/reference/classExpression.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/classes/classExpression.ts === +var x = class C { +>x : Symbol(x, Decl(classExpression.ts, 0, 3)) +>C : Symbol(C, Decl(classExpression.ts, 0, 7)) +} + +var y = { +>y : Symbol(y, Decl(classExpression.ts, 3, 3)) + + foo: class C2 { +>foo : Symbol(foo, Decl(classExpression.ts, 3, 9)) +>C2 : Symbol(C2, Decl(classExpression.ts, 4, 8)) + } +} + +module M { +>M : Symbol(M, Decl(classExpression.ts, 6, 1)) + + var z = class C4 { +>z : Symbol(z, Decl(classExpression.ts, 9, 7)) +>C4 : Symbol(C4, Decl(classExpression.ts, 9, 11)) + } +} diff --git a/tests/baselines/reference/classExpression.types b/tests/baselines/reference/classExpression.types new file mode 100644 index 00000000000..1c55ce89544 --- /dev/null +++ b/tests/baselines/reference/classExpression.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/classes/classExpression.ts === +var x = class C { +>x : typeof C +>class C {} : typeof C +>C : typeof C +} + +var y = { +>y : { foo: typeof C2; } +>{ foo: class C2 { }} : { foo: typeof C2; } + + foo: class C2 { +>foo : typeof C2 +>class C2 { } : typeof C2 +>C2 : typeof C2 + } +} + +module M { +>M : typeof M + + var z = class C4 { +>z : typeof C4 +>class C4 { } : typeof C4 +>C4 : typeof C4 + } +} diff --git a/tests/baselines/reference/classExpression1.errors.txt b/tests/baselines/reference/classExpression1.errors.txt deleted file mode 100644 index 9d7d14d8571..00000000000 --- a/tests/baselines/reference/classExpression1.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/classes/classExpressions/classExpression1.ts(1,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/conformance/classes/classExpressions/classExpression1.ts (1 errors) ==== - var v = class C {}; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpression1.symbols b/tests/baselines/reference/classExpression1.symbols new file mode 100644 index 00000000000..8d3bad269b4 --- /dev/null +++ b/tests/baselines/reference/classExpression1.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression1.ts === +var v = class C {}; +>v : Symbol(v, Decl(classExpression1.ts, 0, 3)) +>C : Symbol(C, Decl(classExpression1.ts, 0, 7)) + diff --git a/tests/baselines/reference/classExpression1.types b/tests/baselines/reference/classExpression1.types new file mode 100644 index 00000000000..4bea3183118 --- /dev/null +++ b/tests/baselines/reference/classExpression1.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression1.ts === +var v = class C {}; +>v : typeof C +>class C {} : typeof C +>C : typeof C + diff --git a/tests/baselines/reference/classExpression2.errors.txt b/tests/baselines/reference/classExpression2.errors.txt deleted file mode 100644 index e2f3ccd77cd..00000000000 --- a/tests/baselines/reference/classExpression2.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/classes/classExpressions/classExpression2.ts(2,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/conformance/classes/classExpressions/classExpression2.ts (1 errors) ==== - class D { } - var v = class C extends D {}; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpression2.js b/tests/baselines/reference/classExpression2.js index 4220b88fb11..f74bb8bd5e2 100644 --- a/tests/baselines/reference/classExpression2.js +++ b/tests/baselines/reference/classExpression2.js @@ -3,6 +3,11 @@ class D { } var v = class C extends D {}; //// [classExpression2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; var D = (function () { function D() { } diff --git a/tests/baselines/reference/classExpression2.symbols b/tests/baselines/reference/classExpression2.symbols new file mode 100644 index 00000000000..11c78a2cad2 --- /dev/null +++ b/tests/baselines/reference/classExpression2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression2.ts === +class D { } +>D : Symbol(D, Decl(classExpression2.ts, 0, 0)) + +var v = class C extends D {}; +>v : Symbol(v, Decl(classExpression2.ts, 1, 3)) +>C : Symbol(C, Decl(classExpression2.ts, 1, 7)) +>D : Symbol(D, Decl(classExpression2.ts, 0, 0)) + diff --git a/tests/baselines/reference/classExpression2.types b/tests/baselines/reference/classExpression2.types new file mode 100644 index 00000000000..4dd6595fb49 --- /dev/null +++ b/tests/baselines/reference/classExpression2.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression2.ts === +class D { } +>D : D + +var v = class C extends D {}; +>v : typeof C +>class C extends D {} : typeof C +>C : typeof C +>D : D + diff --git a/tests/baselines/reference/classExpression3.js b/tests/baselines/reference/classExpression3.js new file mode 100644 index 00000000000..ec9581eaf39 --- /dev/null +++ b/tests/baselines/reference/classExpression3.js @@ -0,0 +1,38 @@ +//// [classExpression3.ts] +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +let c = new C(); +c.a; +c.b; +c.c; + + +//// [classExpression3.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function (_super) { + __extends(class_1, _super); + function class_1() { + _super.apply(this, arguments); + this.c = 3; + } + return class_1; +})((function (_super) { + __extends(class_2, _super); + function class_2() { + _super.apply(this, arguments); + this.b = 2; + } + return class_2; +})((function () { + function class_3() { + this.a = 1; + } + return class_3; +})())); +var c = new C(); +c.a; +c.b; +c.c; diff --git a/tests/baselines/reference/classExpression3.symbols b/tests/baselines/reference/classExpression3.symbols new file mode 100644 index 00000000000..bc1b263a000 --- /dev/null +++ b/tests/baselines/reference/classExpression3.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression3.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : Symbol(C, Decl(classExpression3.ts, 0, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) +>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) +>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) + +let c = new C(); +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>C : Symbol(C, Decl(classExpression3.ts, 0, 3)) + +c.a; +>c.a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) + +c.b; +>c.b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) + +c.c; +>c.c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) + diff --git a/tests/baselines/reference/classExpression3.types b/tests/baselines/reference/classExpression3.types new file mode 100644 index 00000000000..87423ecf0bd --- /dev/null +++ b/tests/baselines/reference/classExpression3.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression3.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : typeof (Anonymous class) +>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class) +>class extends class { a = 1 } { b = 2 } : (Anonymous class) +>class { a = 1 } : (Anonymous class) +>a : number +>1 : number +>b : number +>2 : number +>c : number +>3 : number + +let c = new C(); +>c : (Anonymous class) +>new C() : (Anonymous class) +>C : typeof (Anonymous class) + +c.a; +>c.a : number +>c : (Anonymous class) +>a : number + +c.b; +>c.b : number +>c : (Anonymous class) +>b : number + +c.c; +>c.c : number +>c : (Anonymous class) +>c : number + diff --git a/tests/baselines/reference/classExpression4.js b/tests/baselines/reference/classExpression4.js new file mode 100644 index 00000000000..c2ead0474e2 --- /dev/null +++ b/tests/baselines/reference/classExpression4.js @@ -0,0 +1,19 @@ +//// [classExpression4.ts] +let C = class { + foo() { + return new C(); + } +}; +let x = (new C).foo(); + + +//// [classExpression4.js] +var C = (function () { + function class_1() { + } + class_1.prototype.foo = function () { + return new C(); + }; + return class_1; +})(); +var x = (new C).foo(); diff --git a/tests/baselines/reference/classExpression4.symbols b/tests/baselines/reference/classExpression4.symbols new file mode 100644 index 00000000000..4df5302cecc --- /dev/null +++ b/tests/baselines/reference/classExpression4.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression4.ts === +let C = class { +>C : Symbol(C, Decl(classExpression4.ts, 0, 3)) + + foo() { +>foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15)) + + return new C(); +>C : Symbol(C, Decl(classExpression4.ts, 0, 3)) + } +}; +let x = (new C).foo(); +>x : Symbol(x, Decl(classExpression4.ts, 5, 3)) +>(new C).foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15)) +>C : Symbol(C, Decl(classExpression4.ts, 0, 3)) +>foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15)) + diff --git a/tests/baselines/reference/classExpression4.types b/tests/baselines/reference/classExpression4.types new file mode 100644 index 00000000000..066f169ae74 --- /dev/null +++ b/tests/baselines/reference/classExpression4.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression4.ts === +let C = class { +>C : typeof (Anonymous class) +>class { foo() { return new C(); }} : typeof (Anonymous class) + + foo() { +>foo : () => (Anonymous class) + + return new C(); +>new C() : (Anonymous class) +>C : typeof (Anonymous class) + } +}; +let x = (new C).foo(); +>x : (Anonymous class) +>(new C).foo() : (Anonymous class) +>(new C).foo : () => (Anonymous class) +>(new C) : (Anonymous class) +>new C : (Anonymous class) +>C : typeof (Anonymous class) +>foo : () => (Anonymous class) + diff --git a/tests/baselines/reference/classExpressionES61.errors.txt b/tests/baselines/reference/classExpressionES61.errors.txt deleted file mode 100644 index abaa5ab893c..00000000000 --- a/tests/baselines/reference/classExpressionES61.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/classExpressions/classExpressionES61.ts(1,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/conformance/es6/classExpressions/classExpressionES61.ts (1 errors) ==== - var v = class C {}; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionES61.symbols b/tests/baselines/reference/classExpressionES61.symbols new file mode 100644 index 00000000000..1f49229fbc7 --- /dev/null +++ b/tests/baselines/reference/classExpressionES61.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES61.ts === +var v = class C {}; +>v : Symbol(v, Decl(classExpressionES61.ts, 0, 3)) +>C : Symbol(C, Decl(classExpressionES61.ts, 0, 7)) + diff --git a/tests/baselines/reference/classExpressionES61.types b/tests/baselines/reference/classExpressionES61.types new file mode 100644 index 00000000000..e04570308e8 --- /dev/null +++ b/tests/baselines/reference/classExpressionES61.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES61.ts === +var v = class C {}; +>v : typeof C +>class C {} : typeof C +>C : typeof C + diff --git a/tests/baselines/reference/classExpressionES62.errors.txt b/tests/baselines/reference/classExpressionES62.errors.txt deleted file mode 100644 index 1e28367a17e..00000000000 --- a/tests/baselines/reference/classExpressionES62.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/es6/classExpressions/classExpressionES62.ts(2,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/conformance/es6/classExpressions/classExpressionES62.ts (1 errors) ==== - class D { } - var v = class C extends D {}; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionES62.symbols b/tests/baselines/reference/classExpressionES62.symbols new file mode 100644 index 00000000000..18e1a48ca30 --- /dev/null +++ b/tests/baselines/reference/classExpressionES62.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES62.ts === +class D { } +>D : Symbol(D, Decl(classExpressionES62.ts, 0, 0)) + +var v = class C extends D {}; +>v : Symbol(v, Decl(classExpressionES62.ts, 1, 3)) +>C : Symbol(C, Decl(classExpressionES62.ts, 1, 7)) +>D : Symbol(D, Decl(classExpressionES62.ts, 0, 0)) + diff --git a/tests/baselines/reference/classExpressionES62.types b/tests/baselines/reference/classExpressionES62.types new file mode 100644 index 00000000000..8bb4e1a39ff --- /dev/null +++ b/tests/baselines/reference/classExpressionES62.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES62.ts === +class D { } +>D : D + +var v = class C extends D {}; +>v : typeof C +>class C extends D {} : typeof C +>C : typeof C +>D : D + diff --git a/tests/baselines/reference/classExpressionES63.js b/tests/baselines/reference/classExpressionES63.js new file mode 100644 index 00000000000..6d357af7c5a --- /dev/null +++ b/tests/baselines/reference/classExpressionES63.js @@ -0,0 +1,31 @@ +//// [classExpressionES63.ts] +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +let c = new C(); +c.a; +c.b; +c.c; + + +//// [classExpressionES63.js] +let C = class class_1 extends class class_2 extends class class_3 { + constructor() { + this.a = 1; + } +} + { + constructor(...args) { + super(...args); + this.b = 2; + } +} + { + constructor(...args) { + super(...args); + this.c = 3; + } +} +; +let c = new C(); +c.a; +c.b; +c.c; diff --git a/tests/baselines/reference/classExpressionES63.symbols b/tests/baselines/reference/classExpressionES63.symbols new file mode 100644 index 00000000000..4e52d5ee9dd --- /dev/null +++ b/tests/baselines/reference/classExpressionES63.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) +>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) +>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) + +let c = new C(); +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3)) + +c.a; +>c.a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) + +c.b; +>c.b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) + +c.c; +>c.c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) + diff --git a/tests/baselines/reference/classExpressionES63.types b/tests/baselines/reference/classExpressionES63.types new file mode 100644 index 00000000000..5b07bf79692 --- /dev/null +++ b/tests/baselines/reference/classExpressionES63.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : typeof (Anonymous class) +>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class) +>class extends class { a = 1 } { b = 2 } : (Anonymous class) +>class { a = 1 } : (Anonymous class) +>a : number +>1 : number +>b : number +>2 : number +>c : number +>3 : number + +let c = new C(); +>c : (Anonymous class) +>new C() : (Anonymous class) +>C : typeof (Anonymous class) + +c.a; +>c.a : number +>c : (Anonymous class) +>a : number + +c.b; +>c.b : number +>c : (Anonymous class) +>b : number + +c.c; +>c.c : number +>c : (Anonymous class) +>c : number + diff --git a/tests/baselines/reference/classExpressionTest2.errors.txt b/tests/baselines/reference/classExpressionTest2.errors.txt deleted file mode 100644 index 424eb590611..00000000000 --- a/tests/baselines/reference/classExpressionTest2.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/classExpressionTest2.ts(2,19): error TS9003: 'class' expressions are not currently supported. -tests/cases/compiler/classExpressionTest2.ts(5,20): error TS2304: Cannot find name 'X'. - - -==== tests/cases/compiler/classExpressionTest2.ts (2 errors) ==== - function M() { - var m = class C { - ~ -!!! error TS9003: 'class' expressions are not currently supported. - f() { - var t: T; - var x: X; - ~ -!!! error TS2304: Cannot find name 'X'. - return { t, x }; - } - } - - var v = new m(); - return v.f(); - } \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionTest2.symbols b/tests/baselines/reference/classExpressionTest2.symbols new file mode 100644 index 00000000000..62143cf0b9f --- /dev/null +++ b/tests/baselines/reference/classExpressionTest2.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/classExpressionTest2.ts === +function M() { +>M : Symbol(M, Decl(classExpressionTest2.ts, 0, 0)) + + var m = class C { +>m : Symbol(m, Decl(classExpressionTest2.ts, 1, 7)) +>C : Symbol(C, Decl(classExpressionTest2.ts, 1, 11)) +>X : Symbol(X, Decl(classExpressionTest2.ts, 1, 20)) + + f() { +>f : Symbol(C.f, Decl(classExpressionTest2.ts, 1, 24)) +>T : Symbol(T, Decl(classExpressionTest2.ts, 2, 10)) + + var t: T; +>t : Symbol(t, Decl(classExpressionTest2.ts, 3, 15)) +>T : Symbol(T, Decl(classExpressionTest2.ts, 2, 10)) + + var x: X; +>x : Symbol(x, Decl(classExpressionTest2.ts, 4, 15)) +>X : Symbol(X, Decl(classExpressionTest2.ts, 1, 20)) + + return { t, x }; +>t : Symbol(t, Decl(classExpressionTest2.ts, 5, 20)) +>x : Symbol(x, Decl(classExpressionTest2.ts, 5, 23)) + } + } + + var v = new m(); +>v : Symbol(v, Decl(classExpressionTest2.ts, 9, 7)) +>m : Symbol(m, Decl(classExpressionTest2.ts, 1, 7)) + + return v.f(); +>v.f : Symbol(C.f, Decl(classExpressionTest2.ts, 1, 24)) +>v : Symbol(v, Decl(classExpressionTest2.ts, 9, 7)) +>f : Symbol(C.f, Decl(classExpressionTest2.ts, 1, 24)) +} diff --git a/tests/baselines/reference/classExpressionTest2.types b/tests/baselines/reference/classExpressionTest2.types new file mode 100644 index 00000000000..5586b451d3a --- /dev/null +++ b/tests/baselines/reference/classExpressionTest2.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/classExpressionTest2.ts === +function M() { +>M : () => { t: string; x: number; } + + var m = class C { +>m : typeof C +>class C { f() { var t: T; var x: X; return { t, x }; } } : typeof C +>C : typeof C +>X : X + + f() { +>f : () => { t: T; x: X; } +>T : T + + var t: T; +>t : T +>T : T + + var x: X; +>x : X +>X : X + + return { t, x }; +>{ t, x } : { t: T; x: X; } +>t : T +>x : X + } + } + + var v = new m(); +>v : +>new m() : +>m : typeof C + + return v.f(); +>v.f() : { t: string; x: number; } +>v.f : () => { t: T; x: number; } +>v : +>f : () => { t: T; x: number; } +} diff --git a/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.errors.txt b/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.errors.txt deleted file mode 100644 index 8edc1d8f74b..00000000000 --- a/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/classExpressionWithResolutionOfNamespaceOfSameName01.ts(6,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/compiler/classExpressionWithResolutionOfNamespaceOfSameName01.ts (1 errors) ==== - namespace C { - export interface type { - } - } - - var x = class C { - ~ -!!! error TS9003: 'class' expressions are not currently supported. - prop: C.type; - } \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.symbols b/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.symbols new file mode 100644 index 00000000000..fcd4f0388db --- /dev/null +++ b/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/classExpressionWithResolutionOfNamespaceOfSameName01.ts === +namespace C { +>C : Symbol(C, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 0, 0)) + + export interface type { +>type : Symbol(type, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 0, 13)) + } +} + +var x = class C { +>x : Symbol(x, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 5, 3)) +>C : Symbol(C, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 5, 7)) + + prop: C.type; +>prop : Symbol(C.prop, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 5, 17)) +>C : Symbol(C, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 0, 0)) +>type : Symbol(C.type, Decl(classExpressionWithResolutionOfNamespaceOfSameName01.ts, 0, 13)) +} diff --git a/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.types b/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.types new file mode 100644 index 00000000000..643cf65d2e0 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithResolutionOfNamespaceOfSameName01.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/classExpressionWithResolutionOfNamespaceOfSameName01.ts === +namespace C { +>C : any + + export interface type { +>type : type + } +} + +var x = class C { +>x : typeof C +>class C { prop: C.type;} : typeof C +>C : typeof C + + prop: C.type; +>prop : C.type +>C : any +>type : C.type +} diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.errors.txt b/tests/baselines/reference/classExpressionWithStaticProperties1.errors.txt deleted file mode 100644 index 28e42dd33f1..00000000000 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/classExpressionWithStaticProperties1.ts(1,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/compiler/classExpressionWithStaticProperties1.ts (1 errors) ==== - var v = class C { static a = 1; static b = 2 }; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.symbols b/tests/baselines/reference/classExpressionWithStaticProperties1.symbols new file mode 100644 index 00000000000..d4c811daebe --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties1.ts === +var v = class C { static a = 1; static b = 2 }; +>v : Symbol(v, Decl(classExpressionWithStaticProperties1.ts, 0, 3)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 0, 31)) + diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.types b/tests/baselines/reference/classExpressionWithStaticProperties1.types new file mode 100644 index 00000000000..b014f78abf7 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties1.ts === +var v = class C { static a = 1; static b = 2 }; +>v : typeof C +>class C { static a = 1; static b = 2 } : typeof C +>C : typeof C +>a : number +>1 : number +>b : number +>2 : number + diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.errors.txt b/tests/baselines/reference/classExpressionWithStaticProperties2.errors.txt deleted file mode 100644 index 9a915f70193..00000000000 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/classExpressionWithStaticProperties2.ts(1,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/compiler/classExpressionWithStaticProperties2.ts (1 errors) ==== - var v = class C { static a = 1; static b }; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.symbols b/tests/baselines/reference/classExpressionWithStaticProperties2.symbols new file mode 100644 index 00000000000..480123a1c3b --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties2.ts === +var v = class C { static a = 1; static b }; +>v : Symbol(v, Decl(classExpressionWithStaticProperties2.ts, 0, 3)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties2.ts, 0, 17)) +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 0, 31)) + diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.types b/tests/baselines/reference/classExpressionWithStaticProperties2.types new file mode 100644 index 00000000000..9bfd6732350 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties2.ts === +var v = class C { static a = 1; static b }; +>v : typeof C +>class C { static a = 1; static b } : typeof C +>C : typeof C +>a : number +>1 : number +>b : any + diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.errors.txt b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.errors.txt deleted file mode 100644 index bc015a3d8f0..00000000000 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts(1,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts (1 errors) ==== - var v = class C { static a = 1; static b = 2 }; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols new file mode 100644 index 00000000000..c5f53e19bff --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts === +var v = class C { static a = 1; static b = 2 }; +>v : Symbol(v, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 3)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17)) +>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 31)) + diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types new file mode 100644 index 00000000000..02c385b7525 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts === +var v = class C { static a = 1; static b = 2 }; +>v : typeof C +>class C { static a = 1; static b = 2 } : typeof C +>C : typeof C +>a : number +>1 : number +>b : number +>2 : number + diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.errors.txt b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.errors.txt deleted file mode 100644 index bed4b2c01aa..00000000000 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts(1,15): error TS9003: 'class' expressions are not currently supported. - - -==== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts (1 errors) ==== - var v = class C { static a = 1; static b }; - ~ -!!! error TS9003: 'class' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols new file mode 100644 index 00000000000..be57a289f53 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts === +var v = class C { static a = 1; static b }; +>v : Symbol(v, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 3)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17)) +>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 31)) + diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types new file mode 100644 index 00000000000..e8ded1422f1 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts === +var v = class C { static a = 1; static b }; +>v : typeof C +>class C { static a = 1; static b } : typeof C +>C : typeof C +>a : number +>1 : number +>b : any + diff --git a/tests/baselines/reference/classExtendingBuiltinType.js b/tests/baselines/reference/classExtendingBuiltinType.js new file mode 100644 index 00000000000..8a4b0dd3849 --- /dev/null +++ b/tests/baselines/reference/classExtendingBuiltinType.js @@ -0,0 +1,89 @@ +//// [classExtendingBuiltinType.ts] +class C1 extends Object { } +class C2 extends Function { } +class C3 extends String { } +class C4 extends Boolean { } +class C5 extends Number { } +class C6 extends Date { } +class C7 extends RegExp { } +class C8 extends Error { } +class C9 extends Array { } +class C10 extends Array { } + + +//// [classExtendingBuiltinType.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + _super.apply(this, arguments); + } + return C1; +})(Object); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + return C2; +})(Function); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + _super.apply(this, arguments); + } + return C3; +})(String); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + _super.apply(this, arguments); + } + return C4; +})(Boolean); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + _super.apply(this, arguments); + } + return C5; +})(Number); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + _super.apply(this, arguments); + } + return C6; +})(Date); +var C7 = (function (_super) { + __extends(C7, _super); + function C7() { + _super.apply(this, arguments); + } + return C7; +})(RegExp); +var C8 = (function (_super) { + __extends(C8, _super); + function C8() { + _super.apply(this, arguments); + } + return C8; +})(Error); +var C9 = (function (_super) { + __extends(C9, _super); + function C9() { + _super.apply(this, arguments); + } + return C9; +})(Array); +var C10 = (function (_super) { + __extends(C10, _super); + function C10() { + _super.apply(this, arguments); + } + return C10; +})(Array); diff --git a/tests/baselines/reference/classExtendingBuiltinType.symbols b/tests/baselines/reference/classExtendingBuiltinType.symbols new file mode 100644 index 00000000000..08e85be570e --- /dev/null +++ b/tests/baselines/reference/classExtendingBuiltinType.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts === +class C1 extends Object { } +>C1 : Symbol(C1, Decl(classExtendingBuiltinType.ts, 0, 0)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) + +class C2 extends Function { } +>C2 : Symbol(C2, Decl(classExtendingBuiltinType.ts, 0, 27)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) + +class C3 extends String { } +>C3 : Symbol(C3, Decl(classExtendingBuiltinType.ts, 1, 29)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11)) + +class C4 extends Boolean { } +>C4 : Symbol(C4, Decl(classExtendingBuiltinType.ts, 2, 27)) +>Boolean : Symbol(Boolean, Decl(lib.d.ts, 443, 38), Decl(lib.d.ts, 456, 11)) + +class C5 extends Number { } +>C5 : Symbol(C5, Decl(classExtendingBuiltinType.ts, 3, 28)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) + +class C6 extends Date { } +>C6 : Symbol(C6, Decl(classExtendingBuiltinType.ts, 4, 27)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + +class C7 extends RegExp { } +>C7 : Symbol(C7, Decl(classExtendingBuiltinType.ts, 5, 25)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, 825, 1), Decl(lib.d.ts, 876, 11)) + +class C8 extends Error { } +>C8 : Symbol(C8, Decl(classExtendingBuiltinType.ts, 6, 27)) +>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) + +class C9 extends Array { } +>C9 : Symbol(C9, Decl(classExtendingBuiltinType.ts, 7, 26)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + +class C10 extends Array { } +>C10 : Symbol(C10, Decl(classExtendingBuiltinType.ts, 8, 26)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + diff --git a/tests/baselines/reference/classExtendingBuiltinType.types b/tests/baselines/reference/classExtendingBuiltinType.types new file mode 100644 index 00000000000..b50137e58d6 --- /dev/null +++ b/tests/baselines/reference/classExtendingBuiltinType.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts === +class C1 extends Object { } +>C1 : C1 +>Object : Object + +class C2 extends Function { } +>C2 : C2 +>Function : Function + +class C3 extends String { } +>C3 : C3 +>String : String + +class C4 extends Boolean { } +>C4 : C4 +>Boolean : Boolean + +class C5 extends Number { } +>C5 : C5 +>Number : Number + +class C6 extends Date { } +>C6 : C6 +>Date : Date + +class C7 extends RegExp { } +>C7 : C7 +>RegExp : RegExp + +class C8 extends Error { } +>C8 : C8 +>Error : Error + +class C9 extends Array { } +>C9 : C9 +>Array : any[] + +class C10 extends Array { } +>C10 : C10 +>Array : number[] + diff --git a/tests/baselines/reference/classExtendingClass.js b/tests/baselines/reference/classExtendingClass.js index b8e079e8ecb..6168cb3418d 100644 --- a/tests/baselines/reference/classExtendingClass.js +++ b/tests/baselines/reference/classExtendingClass.js @@ -35,8 +35,7 @@ var r8 = D2.other(1); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/classExtendingClassLikeType.errors.txt b/tests/baselines/reference/classExtendingClassLikeType.errors.txt new file mode 100644 index 00000000000..6f9aef927ea --- /dev/null +++ b/tests/baselines/reference/classExtendingClassLikeType.errors.txt @@ -0,0 +1,70 @@ +tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2304: Cannot find name 'Base'. +tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(45,18): error TS2508: No base constructor has the specified number of type arguments. +tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(56,18): error TS2510: Base constructors must all have the same return type. + + +==== tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts (3 errors) ==== + interface Base { + x: T; + y: U; + } + + // Error, no Base constructor function + class D0 extends Base { + ~~~~ +!!! error TS2304: Cannot find name 'Base'. + } + + interface BaseConstructor { + new (x: string, y: string): Base; + new (x: T): Base; + new (x: T, y: T): Base; + new (x: T, y: U): Base; + } + + declare function getBase(): BaseConstructor; + + class D1 extends getBase() { + constructor() { + super("abc", "def"); + this.x = "x"; + this.y = "y"; + } + } + + class D2 extends getBase() { + constructor() { + super(10); + super(10, 20); + this.x = 1; + this.y = 2; + } + } + + class D3 extends getBase() { + constructor() { + super("abc", 42); + this.x = "x"; + this.y = 2; + } + } + + // Error, no constructors with three type arguments + class D4 extends getBase() { + ~~~~~~~~~ +!!! error TS2508: No base constructor has the specified number of type arguments. + } + + interface BadBaseConstructor { + new (x: string): Base; + new (x: number): Base; + } + + declare function getBadBase(): BadBaseConstructor; + + // Error, constructor return types differ + class D5 extends getBadBase() { + ~~~~~~~~~~~~ +!!! error TS2510: Base constructors must all have the same return type. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingClassLikeType.js b/tests/baselines/reference/classExtendingClassLikeType.js new file mode 100644 index 00000000000..4634b22e493 --- /dev/null +++ b/tests/baselines/reference/classExtendingClassLikeType.js @@ -0,0 +1,118 @@ +//// [classExtendingClassLikeType.ts] +interface Base { + x: T; + y: U; +} + +// Error, no Base constructor function +class D0 extends Base { +} + +interface BaseConstructor { + new (x: string, y: string): Base; + new (x: T): Base; + new (x: T, y: T): Base; + new (x: T, y: U): Base; +} + +declare function getBase(): BaseConstructor; + +class D1 extends getBase() { + constructor() { + super("abc", "def"); + this.x = "x"; + this.y = "y"; + } +} + +class D2 extends getBase() { + constructor() { + super(10); + super(10, 20); + this.x = 1; + this.y = 2; + } +} + +class D3 extends getBase() { + constructor() { + super("abc", 42); + this.x = "x"; + this.y = 2; + } +} + +// Error, no constructors with three type arguments +class D4 extends getBase() { +} + +interface BadBaseConstructor { + new (x: string): Base; + new (x: number): Base; +} + +declare function getBadBase(): BadBaseConstructor; + +// Error, constructor return types differ +class D5 extends getBadBase() { +} + + +//// [classExtendingClassLikeType.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +// Error, no Base constructor function +var D0 = (function (_super) { + __extends(D0, _super); + function D0() { + _super.apply(this, arguments); + } + return D0; +})(Base); +var D1 = (function (_super) { + __extends(D1, _super); + function D1() { + _super.call(this, "abc", "def"); + this.x = "x"; + this.y = "y"; + } + return D1; +})(getBase()); +var D2 = (function (_super) { + __extends(D2, _super); + function D2() { + _super.call(this, 10); + _super.call(this, 10, 20); + this.x = 1; + this.y = 2; + } + return D2; +})(getBase()); +var D3 = (function (_super) { + __extends(D3, _super); + function D3() { + _super.call(this, "abc", 42); + this.x = "x"; + this.y = 2; + } + return D3; +})(getBase()); +// Error, no constructors with three type arguments +var D4 = (function (_super) { + __extends(D4, _super); + function D4() { + _super.apply(this, arguments); + } + return D4; +})(getBase()); +// Error, constructor return types differ +var D5 = (function (_super) { + __extends(D5, _super); + function D5() { + _super.apply(this, arguments); + } + return D5; +})(getBadBase()); diff --git a/tests/baselines/reference/classExtendingNonConstructor.errors.txt b/tests/baselines/reference/classExtendingNonConstructor.errors.txt new file mode 100644 index 00000000000..17b3610d252 --- /dev/null +++ b/tests/baselines/reference/classExtendingNonConstructor.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(7,18): error TS2507: Type 'undefined' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(8,18): error TS2507: Type 'boolean' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(9,18): error TS2507: Type 'boolean' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(10,18): error TS2507: Type 'number' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(11,18): error TS2507: Type 'string' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(12,18): error TS2507: Type '{}' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(13,18): error TS2507: Type '() => void' is not a constructor function type. + + +==== tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts (7 errors) ==== + var x: {}; + + function foo() { + this.x = 1; + } + + class C1 extends undefined { } + ~~~~~~~~~ +!!! error TS2507: Type 'undefined' is not a constructor function type. + class C2 extends true { } + ~~~~ +!!! error TS2507: Type 'boolean' is not a constructor function type. + class C3 extends false { } + ~~~~~ +!!! error TS2507: Type 'boolean' is not a constructor function type. + class C4 extends 42 { } + ~~ +!!! error TS2507: Type 'number' is not a constructor function type. + class C5 extends "hello" { } + ~~~~~~~ +!!! error TS2507: Type 'string' is not a constructor function type. + class C6 extends x { } + ~ +!!! error TS2507: Type '{}' is not a constructor function type. + class C7 extends foo { } + ~~~ +!!! error TS2507: Type '() => void' is not a constructor function type. + \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingNonConstructor.js b/tests/baselines/reference/classExtendingNonConstructor.js new file mode 100644 index 00000000000..dff2fdf9ca9 --- /dev/null +++ b/tests/baselines/reference/classExtendingNonConstructor.js @@ -0,0 +1,75 @@ +//// [classExtendingNonConstructor.ts] +var x: {}; + +function foo() { + this.x = 1; +} + +class C1 extends undefined { } +class C2 extends true { } +class C3 extends false { } +class C4 extends 42 { } +class C5 extends "hello" { } +class C6 extends x { } +class C7 extends foo { } + + +//// [classExtendingNonConstructor.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var x; +function foo() { + this.x = 1; +} +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + _super.apply(this, arguments); + } + return C1; +})(undefined); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + return C2; +})(true); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + _super.apply(this, arguments); + } + return C3; +})(false); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + _super.apply(this, arguments); + } + return C4; +})(42); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + _super.apply(this, arguments); + } + return C5; +})("hello"); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + _super.apply(this, arguments); + } + return C6; +})(x); +var C7 = (function (_super) { + __extends(C7, _super); + function C7() { + _super.apply(this, arguments); + } + return C7; +})(foo); diff --git a/tests/baselines/reference/classExtendingNull.js b/tests/baselines/reference/classExtendingNull.js new file mode 100644 index 00000000000..ac8009b9cd9 --- /dev/null +++ b/tests/baselines/reference/classExtendingNull.js @@ -0,0 +1,25 @@ +//// [classExtendingNull.ts] +class C1 extends null { } +class C2 extends (null) { } + + +//// [classExtendingNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + _super.apply(this, arguments); + } + return C1; +})(null); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + return C2; +})((null)); diff --git a/tests/baselines/reference/classExtendingNull.symbols b/tests/baselines/reference/classExtendingNull.symbols new file mode 100644 index 00000000000..37a6162f414 --- /dev/null +++ b/tests/baselines/reference/classExtendingNull.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts === +class C1 extends null { } +>C1 : Symbol(C1, Decl(classExtendingNull.ts, 0, 0)) + +class C2 extends (null) { } +>C2 : Symbol(C2, Decl(classExtendingNull.ts, 0, 25)) + diff --git a/tests/baselines/reference/classExtendingNull.types b/tests/baselines/reference/classExtendingNull.types new file mode 100644 index 00000000000..3c572a3406c --- /dev/null +++ b/tests/baselines/reference/classExtendingNull.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts === +class C1 extends null { } +>C1 : C1 +>null : null + +class C2 extends (null) { } +>C2 : C2 +>(null) : null +>null : null + diff --git a/tests/baselines/reference/classExtendingPrimitive.errors.txt b/tests/baselines/reference/classExtendingPrimitive.errors.txt index ae039640e99..554e0fbecbc 100644 --- a/tests/baselines/reference/classExtendingPrimitive.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive.errors.txt @@ -4,13 +4,12 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(6,18): error TS2304: Cannot find name 'Void'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(7,19): error TS1109: Expression expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(8,18): error TS2304: Cannot find name 'Null'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,19): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(10,18): error TS2304: Cannot find name 'undefined'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(10,18): error TS2507: Type 'undefined' is not a constructor function type. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(11,18): error TS2304: Cannot find name 'Undefined'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(14,18): error TS2311: A class may only extend another class. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(14,18): error TS2507: Type 'typeof E' is not a constructor function type. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts (10 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts (9 errors) ==== // classes cannot extend primitives class C extends number { } @@ -32,11 +31,9 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla ~~~~ !!! error TS2304: Cannot find name 'Null'. class C5a extends null { } - ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. class C6 extends undefined { } ~~~~~~~~~ -!!! error TS2304: Cannot find name 'undefined'. +!!! error TS2507: Type 'undefined' is not a constructor function type. class C7 extends Undefined { } ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. @@ -44,4 +41,4 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla enum E { A } class C8 extends E { } ~ -!!! error TS2311: A class may only extend another class. \ No newline at end of file +!!! error TS2507: Type 'typeof E' is not a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingPrimitive.js b/tests/baselines/reference/classExtendingPrimitive.js index b099ce763e8..cafa4eebcd1 100644 --- a/tests/baselines/reference/classExtendingPrimitive.js +++ b/tests/baselines/reference/classExtendingPrimitive.js @@ -19,8 +19,7 @@ class C8 extends E { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/classExtendingPrimitive2.errors.txt b/tests/baselines/reference/classExtendingPrimitive2.errors.txt index 3bba9b9e041..2303ca6323d 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive2.errors.txt @@ -1,13 +1,10 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(3,19): error TS1109: Expression expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,19): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts (1 errors) ==== // classes cannot extend primitives class C4a extends void {} ~~~~ !!! error TS1109: Expression expected. - class C5a extends null { } - ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. \ No newline at end of file + class C5a extends null { } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingPrimitive2.js b/tests/baselines/reference/classExtendingPrimitive2.js index 3dcff0b44b9..4661ab961c9 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.js +++ b/tests/baselines/reference/classExtendingPrimitive2.js @@ -9,8 +9,7 @@ class C5a extends null { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C4a = (function () { function C4a() { diff --git a/tests/baselines/reference/classExtendingQualifiedName.errors.txt b/tests/baselines/reference/classExtendingQualifiedName.errors.txt index b63b3e23108..f04d07c89e6 100644 --- a/tests/baselines/reference/classExtendingQualifiedName.errors.txt +++ b/tests/baselines/reference/classExtendingQualifiedName.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendingQualifiedName.ts(5,23): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/compiler/classExtendingQualifiedName.ts(5,23): error TS2339: Property 'C' does not exist on type 'typeof M'. ==== tests/cases/compiler/classExtendingQualifiedName.ts (1 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/classExtendingQualifiedName.ts(5,23): error TS2305: Module class D extends M.C { ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2339: Property 'C' does not exist on type 'typeof M'. } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingQualifiedName.js b/tests/baselines/reference/classExtendingQualifiedName.js index 0289797d1e3..44a4fbe2bd6 100644 --- a/tests/baselines/reference/classExtendingQualifiedName.js +++ b/tests/baselines/reference/classExtendingQualifiedName.js @@ -11,8 +11,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/classExtendingQualifiedName2.js b/tests/baselines/reference/classExtendingQualifiedName2.js index 76065ccc577..afd432180d4 100644 --- a/tests/baselines/reference/classExtendingQualifiedName2.js +++ b/tests/baselines/reference/classExtendingQualifiedName2.js @@ -11,8 +11,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/classExtendingQualifiedName2.types b/tests/baselines/reference/classExtendingQualifiedName2.types index 9f0c03db17d..bd50fe3d2ce 100644 --- a/tests/baselines/reference/classExtendingQualifiedName2.types +++ b/tests/baselines/reference/classExtendingQualifiedName2.types @@ -8,8 +8,8 @@ module M { class D extends M.C { >D : D ->M.C : any +>M.C : C >M : typeof M ->C : C +>C : typeof C } } diff --git a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt index 50c90389520..dfac4f68885 100644 --- a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt +++ b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts(10,21): error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts(10,21): error TS2507: Type 'number' is not a constructor function type. ==== tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstruct var A = 1; class B extends A { ~ -!!! error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +!!! error TS2507: Type 'number' is not a constructor function type. b: string; } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js index 726f918f4e8..fe8dc79b864 100644 --- a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js @@ -17,8 +17,7 @@ module Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt index 7f8b6fb411b..ff355ec653c 100644 --- a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt +++ b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts(4,21): error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts(4,21): error TS2507: Type 'number' is not a constructor function type. ==== tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts(4,21): er var A = 1; class B extends A { b: string; } ~ -!!! error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +!!! error TS2507: Type 'number' is not a constructor function type. } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js index 8dc3410a179..94c50679151 100644 --- a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js @@ -10,8 +10,7 @@ module Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt index 75eced53139..0339dfad13a 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt @@ -1,40 +1,43 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2311: A class may only extend another class. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2304: Cannot find name 'I'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS2507: Type '{ foo: any; }' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,25): error TS2304: Cannot find name 'string'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,31): error TS1005: ',' expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2304: Cannot find name 'x'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(11,18): error TS2304: Cannot find name 'M'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(14,18): error TS2304: Cannot find name 'foo'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2507: Type '{ foo: string; }' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(11,18): error TS2507: Type 'typeof M' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(14,18): error TS2507: Type '() => void' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS2507: Type 'undefined[]' is not a constructor function type. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (7 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (8 errors) ==== interface I { foo: string; } class C extends I { } // error ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'I'. class C2 extends { foo: string; } { } // error ~~~~~~~~~~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Type '{ foo: any; }' is not a constructor function type. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. ~ !!! error TS1005: ',' expected. var x: { foo: string; } class C3 extends x { } // error ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2507: Type '{ foo: string; }' is not a constructor function type. module M { export var x = 1; } class C4 extends M { } // error ~ -!!! error TS2304: Cannot find name 'M'. +!!! error TS2507: Type 'typeof M' is not a constructor function type. function foo() { } class C5 extends foo { } // error ~~~ -!!! error TS2304: Cannot find name 'foo'. +!!! error TS2507: Type '() => void' is not a constructor function type. class C6 extends []{ } // error ~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. \ No newline at end of file +!!! error TS2507: Type 'undefined[]' is not a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsEveryObjectType.js b/tests/baselines/reference/classExtendsEveryObjectType.js index afbb4dab714..92414c7e6c3 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.js +++ b/tests/baselines/reference/classExtendsEveryObjectType.js @@ -20,8 +20,7 @@ class C6 extends []{ } // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt index 45a63030d00..af52a248b54 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt @@ -1,15 +1,18 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,18): error TS2507: Type '{ foo: any; }' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,25): error TS2304: Cannot find name 'string'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,31): error TS1005: ',' expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS2507: Type 'undefined[]' is not a constructor function type. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (3 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (4 errors) ==== class C2 extends { foo: string; } { } // error ~~~~~~~~~~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Type '{ foo: any; }' is not a constructor function type. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. ~ !!! error TS1005: ',' expected. class C6 extends []{ } // error ~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. \ No newline at end of file +!!! error TS2507: Type 'undefined[]' is not a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.js b/tests/baselines/reference/classExtendsEveryObjectType2.js index c41943072dd..2735032f3c4 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.js +++ b/tests/baselines/reference/classExtendsEveryObjectType2.js @@ -7,8 +7,7 @@ class C6 extends []{ } // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C2 = (function (_super) { __extends(C2, _super); diff --git a/tests/baselines/reference/classExtendsInterface.errors.txt b/tests/baselines/reference/classExtendsInterface.errors.txt index 746f3c4bea0..2ecca6cf2cf 100644 --- a/tests/baselines/reference/classExtendsInterface.errors.txt +++ b/tests/baselines/reference/classExtendsInterface.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/classExtendsInterface.ts(2,17): error TS2311: A class may only extend another class. -tests/cases/compiler/classExtendsInterface.ts(6,21): error TS2311: A class may only extend another class. +tests/cases/compiler/classExtendsInterface.ts(2,17): error TS2304: Cannot find name 'Comparable'. +tests/cases/compiler/classExtendsInterface.ts(6,21): error TS2304: Cannot find name 'Comparable2'. ==== tests/cases/compiler/classExtendsInterface.ts (2 errors) ==== interface Comparable {} class A extends Comparable {} ~~~~~~~~~~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'Comparable'. class B implements Comparable {} interface Comparable2 {} class A2 extends Comparable2 {} - ~~~~~~~~~~~~~~ -!!! error TS2311: A class may only extend another class. + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'Comparable2'. class B2 implements Comparable2 {} \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsInterface.js b/tests/baselines/reference/classExtendsInterface.js index a3e596299fa..9b78cde35e9 100644 --- a/tests/baselines/reference/classExtendsInterface.js +++ b/tests/baselines/reference/classExtendsInterface.js @@ -12,8 +12,7 @@ class B2 implements Comparable2 {} var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function (_super) { __extends(A, _super); diff --git a/tests/baselines/reference/classExtendsItself.errors.txt b/tests/baselines/reference/classExtendsItself.errors.txt index bd15ae22c12..9dd3bcc2202 100644 --- a/tests/baselines/reference/classExtendsItself.errors.txt +++ b/tests/baselines/reference/classExtendsItself.errors.txt @@ -1,17 +1,17 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(3,7): error TS2310: Type 'D' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(5,7): error TS2310: Type 'E' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(3,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(5,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts (3 errors) ==== class C extends C { } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. class D extends D { } // error ~ -!!! error TS2310: Type 'D' recursively references itself as a base type. +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. class E extends E { } // error ~ -!!! error TS2310: Type 'E' recursively references itself as a base type. \ No newline at end of file +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItself.js b/tests/baselines/reference/classExtendsItself.js index 79a4226731f..c370e797a57 100644 --- a/tests/baselines/reference/classExtendsItself.js +++ b/tests/baselines/reference/classExtendsItself.js @@ -9,8 +9,7 @@ class E extends E { } // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt index b39ef5b905f..c0f35f0388f 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt @@ -1,20 +1,32 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,7): error TS2310: Type 'C2' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(3,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(5,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,7): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(9,7): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(11,7): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (6 errors) ==== class C extends E { foo: string; } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. class D extends C { bar: string; } + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. class E extends D { baz: number; } + ~ +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. class C2 extends E2 { foo: T; } // error ~~ -!!! error TS2310: Type 'C2' recursively references itself as a base type. +!!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. class D2 extends C2 { bar: T; } + ~~ +!!! error TS2506: 'D2' is referenced directly or indirectly in its own base expression. - class E2 extends D2 { baz: T; } \ No newline at end of file + class E2 extends D2 { baz: T; } + ~~ +!!! error TS2506: 'E2' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.js b/tests/baselines/reference/classExtendsItselfIndirectly.js index eee52b877e3..65cd72ce3c8 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly.js @@ -15,8 +15,7 @@ class E2 extends D2 { baz: T; } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt index a61291b5aa9..061770f9b79 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt @@ -1,31 +1,43 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,11): error TS2310: Type 'C2' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(4,18): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(9,18): error TS2506: 'E' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,11): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(16,22): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(20,22): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (6 errors) ==== class C extends N.E { foo: string; } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. module M { export class D extends C { bar: string; } + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. } module N { export class E extends M.D { baz: number; } + ~ +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. } module O { class C2 extends Q.E2 { foo: T; } // error ~~ -!!! error TS2310: Type 'C2' recursively references itself as a base type. +!!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. module P { export class D2 extends C2 { bar: T; } + ~~ +!!! error TS2506: 'D2' is referenced directly or indirectly in its own base expression. } module Q { export class E2 extends P.D2 { baz: T; } + ~~ +!!! error TS2506: 'E2' is referenced directly or indirectly in its own base expression. } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.js b/tests/baselines/reference/classExtendsItselfIndirectly2.js index 02201425cba..c0b46e6cbb6 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.js @@ -26,8 +26,7 @@ module O { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt index 8430ec887b5..411ea4cb580 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt @@ -1,25 +1,37 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file1.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file4.ts(1,7): error TS2310: Type 'C2' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file1.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file2.ts(1,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file3.ts(1,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file4.ts(1,7): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file5.ts(1,7): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file6.ts(1,7): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file1.ts (1 errors) ==== class C extends E { foo: string; } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file2.ts (0 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file2.ts (1 errors) ==== class D extends C { bar: string; } + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file3.ts (0 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file3.ts (1 errors) ==== class E extends D { baz: number; } + ~ +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file4.ts (1 errors) ==== class C2 extends E2 { foo: T; } // error ~~ -!!! error TS2310: Type 'C2' recursively references itself as a base type. +!!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file5.ts (0 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file5.ts (1 errors) ==== class D2 extends C2 { bar: T; } + ~~ +!!! error TS2506: 'D2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file6.ts (0 errors) ==== - class E2 extends D2 { baz: T; } \ No newline at end of file +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file6.ts (1 errors) ==== + class E2 extends D2 { baz: T; } + ~~ +!!! error TS2506: 'E2' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly3.js b/tests/baselines/reference/classExtendsItselfIndirectly3.js index bff6dd92bc9..9241403a7ce 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly3.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly3.js @@ -22,8 +22,7 @@ class E2 extends D2 { baz: T; } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); @@ -36,8 +35,7 @@ var C = (function (_super) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var D = (function (_super) { __extends(D, _super); @@ -50,8 +48,7 @@ var D = (function (_super) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var E = (function (_super) { __extends(E, _super); @@ -64,8 +61,7 @@ var E = (function (_super) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C2 = (function (_super) { __extends(C2, _super); @@ -78,8 +74,7 @@ var C2 = (function (_super) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var D2 = (function (_super) { __extends(D2, _super); @@ -92,8 +87,7 @@ var D2 = (function (_super) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var E2 = (function (_super) { __extends(E2, _super); diff --git a/tests/baselines/reference/classExtendsMultipleBaseClasses.js b/tests/baselines/reference/classExtendsMultipleBaseClasses.js index 7027e85450d..d1ffee30415 100644 --- a/tests/baselines/reference/classExtendsMultipleBaseClasses.js +++ b/tests/baselines/reference/classExtendsMultipleBaseClasses.js @@ -7,8 +7,7 @@ class C extends A,B { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt b/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt index 782dd2a2dbc..3d8c7454255 100644 --- a/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt +++ b/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsShadowedConstructorFunction.ts(5,21): error TS2419: Type name 'C' in extends clause does not reference constructor function for 'C'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsShadowedConstructorFunction.ts(5,21): error TS2507: Type 'number' is not a constructor function type. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsShadowedConstructorFunction.ts (1 errors) ==== @@ -8,7 +8,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla var C = 1; class D extends C { // error, C must evaluate to constructor function ~ -!!! error TS2419: Type name 'C' in extends clause does not reference constructor function for 'C'. +!!! error TS2507: Type 'number' is not a constructor function type. bar: string; } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js index 48f2e791139..164ffdc8493 100644 --- a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js +++ b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js @@ -12,8 +12,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt b/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt index ad2262819ed..fdfd9110ce6 100644 --- a/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt +++ b/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsValidConstructorFunction.ts(5,17): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsValidConstructorFunction.ts(5,17): error TS2507: Type '() => void' is not a constructor function type. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsValidConstructorFunction.ts (1 errors) ==== @@ -8,4 +8,4 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C extends foo { } // error, cannot extend it though ~~~ -!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file +!!! error TS2507: Type '() => void' is not a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsValidConstructorFunction.js b/tests/baselines/reference/classExtendsValidConstructorFunction.js index 411bd3c2fba..448db68db9f 100644 --- a/tests/baselines/reference/classExtendsValidConstructorFunction.js +++ b/tests/baselines/reference/classExtendsValidConstructorFunction.js @@ -9,8 +9,7 @@ class C extends foo { } // error, cannot extend it though var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function foo() { } var x = new foo(); // can be used as a constructor function diff --git a/tests/baselines/reference/classHeritageWithTrailingSeparator.js b/tests/baselines/reference/classHeritageWithTrailingSeparator.js index 6d33f79a4d5..2d5b12d5201 100644 --- a/tests/baselines/reference/classHeritageWithTrailingSeparator.js +++ b/tests/baselines/reference/classHeritageWithTrailingSeparator.js @@ -7,8 +7,7 @@ class D extends C, { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/classImplementsClass2.js b/tests/baselines/reference/classImplementsClass2.js index 49b73bfdb18..490d2706b48 100644 --- a/tests/baselines/reference/classImplementsClass2.js +++ b/tests/baselines/reference/classImplementsClass2.js @@ -17,8 +17,7 @@ c2 = c; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classImplementsClass3.js b/tests/baselines/reference/classImplementsClass3.js index f8773b435bd..00cb49e2da3 100644 --- a/tests/baselines/reference/classImplementsClass3.js +++ b/tests/baselines/reference/classImplementsClass3.js @@ -18,8 +18,7 @@ c2 = c; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classImplementsClass4.js b/tests/baselines/reference/classImplementsClass4.js index cf442b0ad24..0d7508b723b 100644 --- a/tests/baselines/reference/classImplementsClass4.js +++ b/tests/baselines/reference/classImplementsClass4.js @@ -20,8 +20,7 @@ c2 = c; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classImplementsClass5.js b/tests/baselines/reference/classImplementsClass5.js index a648f6bd63f..caacb7b3044 100644 --- a/tests/baselines/reference/classImplementsClass5.js +++ b/tests/baselines/reference/classImplementsClass5.js @@ -21,8 +21,7 @@ c2 = c; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classImplementsClass6.js b/tests/baselines/reference/classImplementsClass6.js index af6f0844d28..2e8d765be89 100644 --- a/tests/baselines/reference/classImplementsClass6.js +++ b/tests/baselines/reference/classImplementsClass6.js @@ -25,8 +25,7 @@ c2.bar(); // should error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classIndexer3.js b/tests/baselines/reference/classIndexer3.js index 9f630b96306..e962c7295f2 100644 --- a/tests/baselines/reference/classIndexer3.js +++ b/tests/baselines/reference/classIndexer3.js @@ -14,8 +14,7 @@ class D123 extends C123 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C123 = (function () { function C123() { diff --git a/tests/baselines/reference/classInheritence.errors.txt b/tests/baselines/reference/classInheritence.errors.txt index 483812c6b5f..cba8c040d6e 100644 --- a/tests/baselines/reference/classInheritence.errors.txt +++ b/tests/baselines/reference/classInheritence.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/classInheritence.ts(2,7): error TS2310: Type 'A' recursively references itself as a base type. +tests/cases/compiler/classInheritence.ts(2,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. ==== tests/cases/compiler/classInheritence.ts (1 errors) ==== class B extends A { } class A extends A { } ~ -!!! error TS2310: Type 'A' recursively references itself as a base type. \ No newline at end of file +!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classInheritence.js b/tests/baselines/reference/classInheritence.js index 374248c3a2c..1e463dd195d 100644 --- a/tests/baselines/reference/classInheritence.js +++ b/tests/baselines/reference/classInheritence.js @@ -6,8 +6,7 @@ class A extends A { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function (_super) { __extends(B, _super); diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.js b/tests/baselines/reference/classIsSubtypeOfBaseType.js index a33bf5499be..a92cfb430bf 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.js +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.js @@ -19,8 +19,7 @@ class Derived2 extends Base<{ bar: string; }> { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt new file mode 100644 index 00000000000..4bbc2d8167d --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: '=' expected. + + +==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (2 errors) ==== + class C { + public {}; + +!!! error TS1146: Declaration expected. + ~ +!!! error TS1005: '=' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.js b/tests/baselines/reference/classMemberWithMissingIdentifier.js new file mode 100644 index 00000000000..cd1825d0da0 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.js @@ -0,0 +1,12 @@ +//// [classMemberWithMissingIdentifier.ts] +class C { + public {}; +} + +//// [classMemberWithMissingIdentifier.js] +var C = (function () { + function C() { + this. = {}; + } + return C; +})(); diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt new file mode 100644 index 00000000000..b21e062e3b0 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,14): error TS2304: Cannot find name 'name'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ']' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2304: Cannot find name 'string'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,25): error TS1005: ',' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1136: Property assignment expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: Cannot find name 'VariableDeclaration'. + + +==== tests/cases/compiler/classMemberWithMissingIdentifier2.ts (8 errors) ==== + class C { + public {[name:string]:VariableDeclaration}; + +!!! error TS1146: Declaration expected. + ~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'name'. + ~ +!!! error TS1005: ']' expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1136: Property assignment expected. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'VariableDeclaration'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.js b/tests/baselines/reference/classMemberWithMissingIdentifier2.js new file mode 100644 index 00000000000..e8494755b22 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.js @@ -0,0 +1,13 @@ +//// [classMemberWithMissingIdentifier2.ts] +class C { + public {[name:string]:VariableDeclaration}; +} + +//// [classMemberWithMissingIdentifier2.js] +var C = (function () { + function C() { + this. = (_a = {}, _a[name] = string, _a.VariableDeclaration = VariableDeclaration, _a); + var _a; + } + return C; +})(); diff --git a/tests/baselines/reference/classOrder2.js b/tests/baselines/reference/classOrder2.js index 8eed39bddeb..fd3fee2e037 100644 --- a/tests/baselines/reference/classOrder2.js +++ b/tests/baselines/reference/classOrder2.js @@ -23,8 +23,7 @@ a.foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function (_super) { __extends(A, _super); diff --git a/tests/baselines/reference/classOrderBug.js b/tests/baselines/reference/classOrderBug.js index ae50152d608..bc3f0e739c4 100644 --- a/tests/baselines/reference/classOrderBug.js +++ b/tests/baselines/reference/classOrderBug.js @@ -19,8 +19,7 @@ class foo extends baz {} var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var bar = (function () { function bar() { diff --git a/tests/baselines/reference/classSideInheritance1.js b/tests/baselines/reference/classSideInheritance1.js index 66cbc0c25c7..6d217149b83 100644 --- a/tests/baselines/reference/classSideInheritance1.js +++ b/tests/baselines/reference/classSideInheritance1.js @@ -19,8 +19,7 @@ C2.bar(); // valid var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/classSideInheritance2.js b/tests/baselines/reference/classSideInheritance2.js index e09301fe85f..fb6f0d8cbb9 100644 --- a/tests/baselines/reference/classSideInheritance2.js +++ b/tests/baselines/reference/classSideInheritance2.js @@ -24,8 +24,7 @@ class TextBase implements IText { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SubText = (function (_super) { __extends(SubText, _super); diff --git a/tests/baselines/reference/classSideInheritance3.js b/tests/baselines/reference/classSideInheritance3.js index a69b6ff0345..0891a7c9e74 100644 --- a/tests/baselines/reference/classSideInheritance3.js +++ b/tests/baselines/reference/classSideInheritance3.js @@ -22,8 +22,7 @@ var r3: typeof A = C; // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(x) { diff --git a/tests/baselines/reference/classUpdateTests.errors.txt b/tests/baselines/reference/classUpdateTests.errors.txt index 536c69023ad..59e9bc9ced1 100644 --- a/tests/baselines/reference/classUpdateTests.errors.txt +++ b/tests/baselines/reference/classUpdateTests.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/classUpdateTests.ts(34,2): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/classUpdateTests.ts(43,18): error TS2335: 'super' can only be referenced in a derived class. -tests/cases/compiler/classUpdateTests.ts(46,17): error TS2311: A class may only extend another class. -tests/cases/compiler/classUpdateTests.ts(47,18): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/compiler/classUpdateTests.ts(63,7): error TS2415: Class 'L' incorrectly extends base class 'G'. Property 'p1' is private in type 'L' but not in type 'G'. @@ -20,7 +18,7 @@ tests/cases/compiler/classUpdateTests.ts(111,15): error TS1005: ';' expected. tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/classUpdateTests.ts (18 errors) ==== +==== tests/cases/compiler/classUpdateTests.ts (16 errors) ==== // // test codegen for instance properties // @@ -71,11 +69,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st } class I extends Object { - ~~~~~~ -!!! error TS2311: A class may only extend another class. constructor() { super(); } // ERROR - no super call allowed - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. } class J extends G { diff --git a/tests/baselines/reference/classUpdateTests.js b/tests/baselines/reference/classUpdateTests.js index 90149d88d9d..95db2680a1c 100644 --- a/tests/baselines/reference/classUpdateTests.js +++ b/tests/baselines/reference/classUpdateTests.js @@ -117,8 +117,7 @@ class R { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // // test codegen for instance properties diff --git a/tests/baselines/reference/classWithBaseClassButNoConstructor.js b/tests/baselines/reference/classWithBaseClassButNoConstructor.js index f1a10b317a1..44e5d39c376 100644 --- a/tests/baselines/reference/classWithBaseClassButNoConstructor.js +++ b/tests/baselines/reference/classWithBaseClassButNoConstructor.js @@ -44,8 +44,7 @@ var d6 = new D(1); // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/classWithConstructors.js b/tests/baselines/reference/classWithConstructors.js index 467738e0966..a36db6ee745 100644 --- a/tests/baselines/reference/classWithConstructors.js +++ b/tests/baselines/reference/classWithConstructors.js @@ -53,8 +53,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var NonGeneric; (function (NonGeneric) { diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 7d86e1c7229..ec8a203d200 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -32,8 +32,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/classWithStaticMembers.js b/tests/baselines/reference/classWithStaticMembers.js index edad6c22c70..34928c37abd 100644 --- a/tests/baselines/reference/classWithStaticMembers.js +++ b/tests/baselines/reference/classWithStaticMembers.js @@ -23,8 +23,7 @@ var r3 = r.foo; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C(a, b) { diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js index 127e0e9f32b..2af85da5b57 100644 --- a/tests/baselines/reference/classdecl.js +++ b/tests/baselines/reference/classdecl.js @@ -97,8 +97,7 @@ class e { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a(ns) { diff --git a/tests/baselines/reference/clodulesDerivedClasses.js b/tests/baselines/reference/clodulesDerivedClasses.js index c37b9f0e96a..652b3f7bac6 100644 --- a/tests/baselines/reference/clodulesDerivedClasses.js +++ b/tests/baselines/reference/clodulesDerivedClasses.js @@ -26,8 +26,7 @@ module Path.Utils { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Shape = (function () { function Shape() { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js index a58f4aa9f94..731f3d4f064 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js @@ -43,8 +43,7 @@ class c extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function _super() { } diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js index b89a8753acd..06acaa0e02a 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js @@ -28,8 +28,7 @@ class c extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function _super() { } diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js index efa9c1d9f03..6702ba8ac3d 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js @@ -32,8 +32,7 @@ class c extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function _super() { } diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js index 228b7243d4f..8d13eed617b 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js @@ -22,8 +22,7 @@ class b extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function _super() { } diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js index d2392f4df38..12685727795 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js @@ -36,8 +36,7 @@ class c extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var _super = 10; // No Error var Foo = (function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js index dc3210c1f8e..6f543492898 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js @@ -24,8 +24,7 @@ class c extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var _super = 10; // No Error var Foo = (function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js index 7a6ee0c45c5..373ee270014 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js @@ -22,8 +22,7 @@ class c extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var _super = 10; // No Error var Foo = (function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js index f678c7cf6ca..7ba9b407858 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js @@ -21,8 +21,7 @@ class b extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var _super = 10; // No Error var Foo = (function () { diff --git a/tests/baselines/reference/collisionSuperAndNameResolution.js b/tests/baselines/reference/collisionSuperAndNameResolution.js index 540a2b659d9..5cddcc01845 100644 --- a/tests/baselines/reference/collisionSuperAndNameResolution.js +++ b/tests/baselines/reference/collisionSuperAndNameResolution.js @@ -15,8 +15,7 @@ class Foo extends base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var console; var _super = 10; // No error diff --git a/tests/baselines/reference/collisionSuperAndParameter.js b/tests/baselines/reference/collisionSuperAndParameter.js index ac8947e00d3..965887d6d1b 100644 --- a/tests/baselines/reference/collisionSuperAndParameter.js +++ b/tests/baselines/reference/collisionSuperAndParameter.js @@ -66,8 +66,7 @@ class Foo4 extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/collisionSuperAndParameter1.js b/tests/baselines/reference/collisionSuperAndParameter1.js index b072667396d..f6d1f23947d 100644 --- a/tests/baselines/reference/collisionSuperAndParameter1.js +++ b/tests/baselines/reference/collisionSuperAndParameter1.js @@ -13,8 +13,7 @@ class Foo2 extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js index e96ae7d8928..f54bbef28a8 100644 --- a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js +++ b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js @@ -34,8 +34,7 @@ class b4 extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js index dbf36111dfb..eb2ddd825fb 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js @@ -22,8 +22,7 @@ class b2 extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/commentOnAmbientModule.types b/tests/baselines/reference/commentOnAmbientModule.types index 13d35cddcea..629395a4e80 100644 --- a/tests/baselines/reference/commentOnAmbientModule.types +++ b/tests/baselines/reference/commentOnAmbientModule.types @@ -5,9 +5,9 @@ declare module E { class foobar extends D.bar { >foobar : foobar ->D.bar : any +>D.bar : D.bar >D : typeof D ->bar : D.bar +>bar : typeof D.bar foo(); >foo : () => any diff --git a/tests/baselines/reference/commentsInheritance.js b/tests/baselines/reference/commentsInheritance.js index 4fe5a30cb8b..33726436189 100644 --- a/tests/baselines/reference/commentsInheritance.js +++ b/tests/baselines/reference/commentsInheritance.js @@ -155,8 +155,7 @@ i2_i = i3_i; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js index aebb486a1b5..d59ec764680 100644 --- a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js @@ -198,8 +198,7 @@ var r8b7 = b6 !== a6; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A1 = (function () { function A1() { diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js index 3d7e96be633..4bbc7675a31 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js @@ -172,8 +172,7 @@ var r8b7 = b7 !== a7; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js index 097246f183b..397c7e9d8e4 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js @@ -172,8 +172,7 @@ var r8b7 = b7 !== a7; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js index 6bb3cddc8a7..9f3c037538d 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js @@ -115,8 +115,7 @@ var r8b4 = b4 !== a4; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js index dee8fb5ed5a..68ebcb9d596 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js @@ -153,8 +153,7 @@ var r8b6 = b6 !== a6; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js index bc7db12ebf2..60177f0ea22 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js @@ -153,8 +153,7 @@ var r8b6 = b6 !== a6; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js index a35ece1b617..27d1b68c85d 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js @@ -263,8 +263,7 @@ var r8b11 = b11 !== a11; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js index 8ade79daa20..5a98e12b001 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js @@ -225,8 +225,7 @@ var r8b9 = b9 !== a9; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js index 080c7990c04..24069615e0a 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js @@ -111,8 +111,7 @@ var r8b1 = b4 !== a4; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js index f01b18496d5..f0dac057ca3 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js @@ -168,8 +168,7 @@ var r8b6 = b6 !== a6; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js index bd4525e5c7b..eaf1aca728d 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js @@ -168,8 +168,7 @@ var r8b6 = b6 !== a6; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js index cbd31f56b30..822d4b7520a 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js @@ -82,8 +82,7 @@ var rh4 = b2 !== a2; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/complexClassRelationships.js b/tests/baselines/reference/complexClassRelationships.js index 2d750b77f71..ca2b31a805c 100644 --- a/tests/baselines/reference/complexClassRelationships.js +++ b/tests/baselines/reference/complexClassRelationships.js @@ -51,8 +51,7 @@ class FooBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // There should be no errors in this file var Derived = (function (_super) { diff --git a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt index 204a7d4c21a..a70eb0e5e2c 100644 --- a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt +++ b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts(1,7): error TS2310: Type 'S18' recursively references itself as a base type. +tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts(1,7): error TS2506: 'S18' is referenced directly or indirectly in its own base expression. tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts(4,2): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts (2 errors) ==== class S18 extends S18 ~~~ -!!! error TS2310: Type 'S18' recursively references itself as a base type. +!!! error TS2506: 'S18' is referenced directly or indirectly in its own base expression. { } (new S18(123)).S18 = 0; diff --git a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js index 920172b206d..71c1cee164f 100644 --- a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js +++ b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js @@ -9,8 +9,7 @@ class S18 extends S18 var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var S18 = (function (_super) { __extends(S18, _super); diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.js b/tests/baselines/reference/compoundAssignmentLHSIsValue.js index 4c5c050dc83..833c1e1ea7c 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.js @@ -126,8 +126,7 @@ foo() += value; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // expected error for all the LHS of compound assignments (arithmetic and addition) var value; diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.js b/tests/baselines/reference/computedPropertyNames24_ES5.js index e433383eb5c..5a4b79cf44a 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.js +++ b/tests/baselines/reference/computedPropertyNames24_ES5.js @@ -12,8 +12,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index eca2485ab7d..832fad174d8 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -17,8 +17,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 0e3b6c126bc..09a95419480 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -14,8 +14,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames27_ES5.js b/tests/baselines/reference/computedPropertyNames27_ES5.js index 12f02fbefa9..53e2c2988c8 100644 --- a/tests/baselines/reference/computedPropertyNames27_ES5.js +++ b/tests/baselines/reference/computedPropertyNames27_ES5.js @@ -9,8 +9,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index b2be5f120a5..be79f22c2da 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -14,8 +14,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index 6bbca3da056..de60b5daf53 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -19,8 +19,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index fb7d651364b..f8e34603305 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -19,8 +19,7 @@ class C extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.js b/tests/baselines/reference/computedPropertyNames43_ES5.js index e51df61a8c1..c3b7f6a71d0 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.js +++ b/tests/baselines/reference/computedPropertyNames43_ES5.js @@ -16,8 +16,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.js b/tests/baselines/reference/computedPropertyNames44_ES5.js index 5efc5a11496..1186f0caef7 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.js +++ b/tests/baselines/reference/computedPropertyNames44_ES5.js @@ -15,8 +15,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.js b/tests/baselines/reference/computedPropertyNames45_ES5.js index d7fb6f35407..ce948e58208 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.js +++ b/tests/baselines/reference/computedPropertyNames45_ES5.js @@ -16,8 +16,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js index 18c09a500a6..a493a5cfab0 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js @@ -51,8 +51,7 @@ var result11: any = true ? 1 : 'string'; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; //Cond ? Expr1 : Expr2, Expr1 and Expr2 have identical best common type var X = (function () { diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js index 62b887d7e60..3d75eb0507a 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js @@ -27,8 +27,7 @@ var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.p var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; //Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type var X = (function () { diff --git a/tests/baselines/reference/constantOverloadFunction.js b/tests/baselines/reference/constantOverloadFunction.js index aa89c619e7e..45c0fe9ff0a 100644 --- a/tests/baselines/reference/constantOverloadFunction.js +++ b/tests/baselines/reference/constantOverloadFunction.js @@ -17,8 +17,7 @@ function foo(tagName: any): Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js index 529f888bfc9..946f8196372 100644 --- a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js +++ b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js @@ -18,8 +18,7 @@ function foo(tagName: any): Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js index 22b77ba6816..9cf9d71f7a2 100644 --- a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js +++ b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js @@ -23,8 +23,7 @@ class Container { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // No errors var Constraint = (function () { diff --git a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types index 1d94a5e464c..6fd80b779c5 100644 --- a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types +++ b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types @@ -16,7 +16,7 @@ class GenericBase { } class Derived extends GenericBase { >Derived : Derived ->GenericBase : GenericBase +>GenericBase : GenericBase >TypeArg : TypeArg } diff --git a/tests/baselines/reference/constraints0.errors.txt b/tests/baselines/reference/constraints0.errors.txt index 217a7408fbd..39cc7654e01 100644 --- a/tests/baselines/reference/constraints0.errors.txt +++ b/tests/baselines/reference/constraints0.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/constraints0.ts(14,9): error TS2344: Type 'B' does not satisfy the constraint 'A'. +tests/cases/compiler/constraints0.ts(14,11): error TS2344: Type 'B' does not satisfy the constraint 'A'. Property 'a' is missing in type 'B'. @@ -17,7 +17,7 @@ tests/cases/compiler/constraints0.ts(14,9): error TS2344: Type 'B' does not sati var v1: C; // should work var v2: C; // should not work - ~~~~ + ~ !!! error TS2344: Type 'B' does not satisfy the constraint 'A'. !!! error TS2344: Property 'a' is missing in type 'B'. diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index c1c10ead1e3..38b7b7fc194 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -74,8 +74,7 @@ interface I extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js index 12907c6d032..7d07c1a1712 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js @@ -117,8 +117,7 @@ module Errors { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Errors; (function (Errors) { diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js index ef03802a17e..ba341eec61f 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js @@ -64,8 +64,7 @@ interface I extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index 9964a3464a1..304b5cafd66 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -54,8 +54,7 @@ interface I extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js index 4cf9b7d71f5..99c885f9716 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js @@ -57,8 +57,7 @@ interface I9 extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constructorArgs.js b/tests/baselines/reference/constructorArgs.js index 93a47178d52..6fc3511b70e 100644 --- a/tests/baselines/reference/constructorArgs.js +++ b/tests/baselines/reference/constructorArgs.js @@ -19,8 +19,7 @@ class Sub extends Super { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Super = (function () { function Super(value) { diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js index 9c92f31ce97..305b3e54ead 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js @@ -23,8 +23,7 @@ class Derived2 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js index 61cf399f613..b2bf377f0cc 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js @@ -37,8 +37,7 @@ class Derived2 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/constructorHasPrototypeProperty.js b/tests/baselines/reference/constructorHasPrototypeProperty.js index 47020120f9f..a1bdee8e7d4 100644 --- a/tests/baselines/reference/constructorHasPrototypeProperty.js +++ b/tests/baselines/reference/constructorHasPrototypeProperty.js @@ -35,8 +35,7 @@ module Generic { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var NonGeneric; (function (NonGeneric) { diff --git a/tests/baselines/reference/constructorOverloads2.js b/tests/baselines/reference/constructorOverloads2.js index 16da3f0fa0a..d95477d84f6 100644 --- a/tests/baselines/reference/constructorOverloads2.js +++ b/tests/baselines/reference/constructorOverloads2.js @@ -29,8 +29,7 @@ f1.bar1(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var FooBase = (function () { function FooBase(x) { diff --git a/tests/baselines/reference/constructorOverloads3.js b/tests/baselines/reference/constructorOverloads3.js index f4299466aa1..c7e4e411319 100644 --- a/tests/baselines/reference/constructorOverloads3.js +++ b/tests/baselines/reference/constructorOverloads3.js @@ -26,8 +26,7 @@ f1.bar1(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function (_super) { __extends(Foo, _super); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index 01a1880ffd5..5a61d4d5d7e 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -283,8 +283,7 @@ TypeScriptAllInOne.Program.Main(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var fs = module; ("fs"); diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.js b/tests/baselines/reference/contextualTypingArrayOfLambdas.js index e24ae90176c..59da607079b 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.js +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.js @@ -18,8 +18,7 @@ var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression.js b/tests/baselines/reference/contextualTypingOfConditionalExpression.js index 72c15455e8e..a0f8ea0a4cf 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression.js @@ -18,8 +18,7 @@ var x2: (a: A) => void = true ? (a) => a.foo : (b) => b.foo; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x = true ? function (a) { return a.toExponential(); } : function (b) { return b.toFixed(); }; var A = (function () { diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js index 4e6b95a6857..2833ed37d4b 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js @@ -16,8 +16,7 @@ var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { }; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js index 17c9ac649d8..332f4897fc7 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js @@ -14,8 +14,7 @@ var a: D = foo("hi", []); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js index 134bacd6053..0f13824fc45 100644 --- a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js +++ b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js @@ -13,8 +13,7 @@ interface I extends X<() => number> { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var X = (function () { function X() { diff --git a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types index 5f759fb423f..ba203e39aab 100644 --- a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types +++ b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types @@ -6,7 +6,7 @@ class X { } class C extends X<() => number> { >C : C ->X : X +>X : X<() => number> } interface I extends X<() => number> { >I : I diff --git a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js index 23630ba5218..caaba28859a 100644 --- a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js +++ b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js @@ -16,8 +16,7 @@ class Baz implements IBar { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/declFileGenericType.js b/tests/baselines/reference/declFileGenericType.js index dfbe147a78d..b67bacebb1a 100644 --- a/tests/baselines/reference/declFileGenericType.js +++ b/tests/baselines/reference/declFileGenericType.js @@ -43,8 +43,7 @@ export var j = C.F6; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C; (function (C) { diff --git a/tests/baselines/reference/declFileGenericType.types b/tests/baselines/reference/declFileGenericType.types index 7aa20187890..310f812a7bb 100644 --- a/tests/baselines/reference/declFileGenericType.types +++ b/tests/baselines/reference/declFileGenericType.types @@ -153,9 +153,9 @@ export var g = C.F5>(); export class h extends C.A{ } >h : h ->C.A : any +>C.A : C.A >C : typeof C ->A : C.A +>A : typeof C.A >C : any >B : C.B diff --git a/tests/baselines/reference/declFileGenericType2.js b/tests/baselines/reference/declFileGenericType2.js index 03649af4ba6..416e0f6737c 100644 --- a/tests/baselines/reference/declFileGenericType2.js +++ b/tests/baselines/reference/declFileGenericType2.js @@ -46,8 +46,7 @@ module templa.dom.mvc.composite { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Module var templa; diff --git a/tests/baselines/reference/declFileGenericType2.types b/tests/baselines/reference/declFileGenericType2.types index e1e1aa0bbfb..07bcba3e85a 100644 --- a/tests/baselines/reference/declFileGenericType2.types +++ b/tests/baselines/reference/declFileGenericType2.types @@ -86,11 +86,11 @@ module templa.dom.mvc { >templa : any >mvc : any >IModel : templa.mvc.IModel ->templa.mvc.AbstractController : any +>templa.mvc.AbstractController : templa.mvc.AbstractController >templa.mvc : typeof templa.mvc >templa : typeof templa >mvc : typeof templa.mvc ->AbstractController : templa.mvc.AbstractController +>AbstractController : typeof templa.mvc.AbstractController >ModelType : ModelType >IElementController : IElementController >ModelType : ModelType @@ -116,13 +116,13 @@ module templa.dom.mvc.composite { >mvc : any >composite : any >ICompositeControllerModel : templa.mvc.composite.ICompositeControllerModel ->templa.dom.mvc.AbstractElementController : any +>templa.dom.mvc.AbstractElementController : AbstractElementController >templa.dom.mvc : typeof mvc >templa.dom : typeof dom >templa : typeof templa >dom : typeof dom >mvc : typeof mvc ->AbstractElementController : AbstractElementController +>AbstractElementController : typeof AbstractElementController >ModelType : ModelType public _controllers: templa.mvc.IController[]; diff --git a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js index 8881122839e..e21c28138a2 100644 --- a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js +++ b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js @@ -24,8 +24,7 @@ module X.Y.base.Z { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var X; (function (X) { diff --git a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types index 56e1d07d0ec..f032ad29b11 100644 --- a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types +++ b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types @@ -19,13 +19,13 @@ module X.Y.base { export class W extends A.B.Base.W { >W : W ->A.B.Base.W : any +>A.B.Base.W : A.B.Base.W >A.B.Base : typeof A.B.Base >A.B : typeof A.B >A : typeof A >B : typeof A.B >Base : typeof A.B.Base ->W : A.B.Base.W +>W : typeof A.B.Base.W name: string; >name : string @@ -41,13 +41,13 @@ module X.Y.base.Z { export class W extends X.Y.base.W { >W : W >TValue : TValue ->X.Y.base.W : any +>X.Y.base.W : base.W >X.Y.base : typeof base >X.Y : typeof Y >X : typeof X >Y : typeof Y >base : typeof base ->W : base.W +>W : typeof base.W value: boolean; >value : boolean diff --git a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js index c06461e89fc..587b8ff1e27 100644 --- a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js +++ b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js @@ -22,8 +22,7 @@ module A.B.C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A; (function (A) { diff --git a/tests/baselines/reference/declarationEmitDestructuring4.js b/tests/baselines/reference/declarationEmitDestructuring4.js index f5d9df09175..16e6b49a4cf 100644 --- a/tests/baselines/reference/declarationEmitDestructuring4.js +++ b/tests/baselines/reference/declarationEmitDestructuring4.js @@ -15,20 +15,16 @@ function baz4({} = { x: 10 }) { } // For an array binding pattern with empty elements, // we will not make any modification and will emit // the similar binding pattern users' have written -function baz(_a) { - var ; -} +function baz(_a) { } function baz1(_a) { - var _b = _a === void 0 ? [1, 2, 3] : _a; + var _a = [1, 2, 3]; } function baz2(_a) { var _b = (_a === void 0 ? [[1, 2, 3]] : _a)[0]; } -function baz3(_a) { - var ; -} +function baz3(_a) { } function baz4(_a) { - var _b = _a === void 0 ? { x: 10 } : _a; + var _a = { x: 10 }; } diff --git a/tests/baselines/reference/declarationEmit_nameConflicts3.js b/tests/baselines/reference/declarationEmit_nameConflicts3.js index ee21d9a408d..07299132bd4 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts3.js +++ b/tests/baselines/reference/declarationEmit_nameConflicts3.js @@ -30,8 +30,7 @@ module M.P { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.js b/tests/baselines/reference/declarationEmit_protectedMembers.js index faa1dc298e1..536f4f4aff7 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.js +++ b/tests/baselines/reference/declarationEmit_protectedMembers.js @@ -54,8 +54,7 @@ class C4 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Class with protected members var C1 = (function () { diff --git a/tests/baselines/reference/declareDottedExtend.js b/tests/baselines/reference/declareDottedExtend.js index 2579a5557fc..030e5048ef7 100644 --- a/tests/baselines/reference/declareDottedExtend.js +++ b/tests/baselines/reference/declareDottedExtend.js @@ -15,8 +15,7 @@ class E extends A.B.C{ } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var ab = A.B; var D = (function (_super) { diff --git a/tests/baselines/reference/declareDottedExtend.types b/tests/baselines/reference/declareDottedExtend.types index 7df6c9ecb7c..1c6c48c85c9 100644 --- a/tests/baselines/reference/declareDottedExtend.types +++ b/tests/baselines/reference/declareDottedExtend.types @@ -14,15 +14,15 @@ import ab = A.B; class D extends ab.C{ } >D : D ->ab.C : any +>ab.C : ab.C >ab : typeof ab ->C : ab.C +>C : typeof ab.C class E extends A.B.C{ } >E : E ->A.B.C : any +>A.B.C : ab.C >A.B : typeof ab >A : typeof A >B : typeof ab ->C : ab.C +>C : typeof ab.C diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.js b/tests/baselines/reference/decoratedClassFromExternalModule.js index 163a4a094b4..aca1d28b952 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.js +++ b/tests/baselines/reference/decoratedClassFromExternalModule.js @@ -1,7 +1,7 @@ //// [tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts] //// //// [decorated.ts] -function decorate() { } +function decorate(target: any) { } @decorate export default class Decorated { } @@ -18,7 +18,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -function decorate() { } +function decorate(target) { } let Decorated = class { }; Decorated = __decorate([ diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.symbols b/tests/baselines/reference/decoratedClassFromExternalModule.symbols index aa17dde616a..60e4a892ec0 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.symbols +++ b/tests/baselines/reference/decoratedClassFromExternalModule.symbols @@ -1,12 +1,13 @@ === tests/cases/conformance/decorators/class/decorated.ts === -function decorate() { } +function decorate(target: any) { } >decorate : Symbol(decorate, Decl(decorated.ts, 0, 0)) +>target : Symbol(target, Decl(decorated.ts, 0, 18)) @decorate >decorate : Symbol(decorate, Decl(decorated.ts, 0, 0)) export default class Decorated { } ->Decorated : Symbol(Decorated, Decl(decorated.ts, 0, 23)) +>Decorated : Symbol(Decorated, Decl(decorated.ts, 0, 34)) === tests/cases/conformance/decorators/class/undecorated.ts === import Decorated from 'decorated'; diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.types b/tests/baselines/reference/decoratedClassFromExternalModule.types index 4234b6a4b15..d4bc3239e46 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.types +++ b/tests/baselines/reference/decoratedClassFromExternalModule.types @@ -1,9 +1,10 @@ === tests/cases/conformance/decorators/class/decorated.ts === -function decorate() { } ->decorate : () => void +function decorate(target: any) { } +>decorate : (target: any) => void +>target : any @decorate ->decorate : () => void +>decorate : (target: any) => void export default class Decorated { } >Decorated : Decorated diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt b/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt index c8166b538fd..cef2f90f704 100644 --- a/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts(9,14): } class A { - @(x => { + @((x, p) => { var a = 3; func(a); ~ diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.js b/tests/baselines/reference/decoratorChecksFunctionBodies.js index 020bc775aea..adb710efccc 100644 --- a/tests/baselines/reference/decoratorChecksFunctionBodies.js +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.js @@ -5,7 +5,7 @@ function func(s: string): void { } class A { - @(x => { + @((x, p) => { var a = 3; func(a); return x; @@ -34,7 +34,7 @@ var A = (function () { }; Object.defineProperty(A.prototype, "m", __decorate([ - (function (x) { + (function (x, p) { var a = 3; func(a); return x; diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js index 313d77fa5ce..08ba6e9ea7e 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js @@ -9,7 +9,7 @@ export var test = 'abc'; import { test } from './a'; function filter(handler: any) { - return function (target: any) { + return function (target: any, propertyKey: string) { // ... }; } @@ -35,7 +35,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; var a_1 = require('./a'); function filter(handler) { - return function (target) { + return function (target, propertyKey) { // ... }; } diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols index 5088e740a57..f7c96097caf 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.symbols @@ -12,8 +12,9 @@ function filter(handler: any) { >filter : Symbol(filter, Decl(b.ts, 0, 27)) >handler : Symbol(handler, Decl(b.ts, 2, 16)) - return function (target: any) { + return function (target: any, propertyKey: string) { >target : Symbol(target, Decl(b.ts, 3, 21)) +>propertyKey : Symbol(propertyKey, Decl(b.ts, 3, 33)) // ... }; diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types index 18d993af9bb..d0f930b7ad4 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types @@ -10,12 +10,13 @@ import { test } from './a'; >test : string function filter(handler: any) { ->filter : (handler: any) => (target: any) => void +>filter : (handler: any) => (target: any, propertyKey: string) => void >handler : any - return function (target: any) { ->function (target: any) { // ... } : (target: any) => void + return function (target: any, propertyKey: string) { +>function (target: any, propertyKey: string) { // ... } : (target: any, propertyKey: string) => void >target : any +>propertyKey : string // ... }; @@ -25,8 +26,8 @@ class Wat { >Wat : Wat @filter(() => test == 'abc') ->filter(() => test == 'abc') : (target: any) => void ->filter : (handler: any) => (target: any) => void +>filter(() => test == 'abc') : (target: any, propertyKey: string) => void +>filter : (handler: any) => (target: any, propertyKey: string) => void >() => test == 'abc' : () => boolean >test == 'abc' : boolean >test : string diff --git a/tests/baselines/reference/decoratorOnClass8.errors.txt b/tests/baselines/reference/decoratorOnClass8.errors.txt index 0a9fbf2956c..f9ca7fca210 100644 --- a/tests/baselines/reference/decoratorOnClass8.errors.txt +++ b/tests/baselines/reference/decoratorOnClass8.errors.txt @@ -1,4 +1,5 @@ -tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'. +tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. + Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/decorators/class/decoratorOnClass8.ts (1 errors) ==== @@ -6,6 +7,7 @@ tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS2322 @dec() ~~~~~~ -!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'. +!!! error TS1238: Unable to resolve signature of class decorator when called as an expression. +!!! error TS1238: Supplied parameters do not match any signature of call target. class C { } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod10.errors.txt b/tests/baselines/reference/decoratorOnClassMethod10.errors.txt index cd331473b7c..6499aa44e53 100644 --- a/tests/baselines/reference/decoratorOnClassMethod10.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod10.errors.txt @@ -1,7 +1,5 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,5): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'. - Types of parameters 'paramIndex' and 'propertyKey' are incompatible. - Type 'number' is not assignable to type 'string | symbol'. - Type 'number' is not assignable to type 'symbol'. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,6): error TS2345: Argument of type 'C' is not assignable to parameter of type 'Function'. + Property 'apply' is missing in type 'C'. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts (1 errors) ==== @@ -9,9 +7,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,5) class C { @dec method() {} - ~~~~ -!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'. -!!! error TS2322: Types of parameters 'paramIndex' and 'propertyKey' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string | symbol'. -!!! error TS2322: Type 'number' is not assignable to type 'symbol'. + ~~~ +!!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'Function'. +!!! error TS2345: Property 'apply' is missing in type 'C'. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index aa938eaaaf4..05c4f285291 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -13,8 +13,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); diff --git a/tests/baselines/reference/decoratorOnClassMethod13.js b/tests/baselines/reference/decoratorOnClassMethod13.js index 967cc05ba4d..b39fa63686a 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.js +++ b/tests/baselines/reference/decoratorOnClassMethod13.js @@ -1,5 +1,5 @@ //// [decoratorOnClassMethod13.ts] -declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { @dec ["1"]() { } diff --git a/tests/baselines/reference/decoratorOnClassMethod13.symbols b/tests/baselines/reference/decoratorOnClassMethod13.symbols index af3819924f4..42f44d885ee 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod13.symbols @@ -1,17 +1,17 @@ === tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts === -declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) ->T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 25)) ->target : Symbol(target, Decl(decoratorOnClassMethod13.ts, 0, 28)) ->propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethod13.ts, 0, 40)) ->descriptor : Symbol(descriptor, Decl(decoratorOnClassMethod13.ts, 0, 61)) +>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 21)) +>target : Symbol(target, Decl(decoratorOnClassMethod13.ts, 0, 24)) +>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethod13.ts, 0, 36)) +>descriptor : Symbol(descriptor, Decl(decoratorOnClassMethod13.ts, 0, 57)) >TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36)) ->T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 25)) +>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 21)) >TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36)) ->T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 25)) +>T : Symbol(T, Decl(decoratorOnClassMethod13.ts, 0, 21)) class C { ->C : Symbol(C, Decl(decoratorOnClassMethod13.ts, 0, 132)) +>C : Symbol(C, Decl(decoratorOnClassMethod13.ts, 0, 126)) @dec ["1"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) diff --git a/tests/baselines/reference/decoratorOnClassMethod13.types b/tests/baselines/reference/decoratorOnClassMethod13.types index 2858f8877bd..5fdbe071828 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.types +++ b/tests/baselines/reference/decoratorOnClassMethod13.types @@ -1,6 +1,6 @@ === tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts === -declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; ->dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor >T : T >target : any >propertyKey : string @@ -14,10 +14,10 @@ class C { >C : C @dec ["1"]() { } ->dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor >"1" : string @dec ["b"]() { } ->dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor >"b" : string } diff --git a/tests/baselines/reference/decoratorOnClassMethod6.errors.txt b/tests/baselines/reference/decoratorOnClassMethod6.errors.txt new file mode 100644 index 00000000000..c8ee66717ef --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts(4,5): error TS1241: Unable to resolve signature of method decorator when called as an expression. + Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts (1 errors) ==== + declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; + + class C { + @dec ["method"]() {} + ~~~~ +!!! error TS1241: Unable to resolve signature of method decorator when called as an expression. +!!! error TS1241: Supplied parameters do not match any signature of call target. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod6.symbols b/tests/baselines/reference/decoratorOnClassMethod6.symbols deleted file mode 100644 index 8dcdd99a8e9..00000000000 --- a/tests/baselines/reference/decoratorOnClassMethod6.symbols +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts === -declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; ->dec : Symbol(dec, Decl(decoratorOnClassMethod6.ts, 0, 0)) ->T : Symbol(T, Decl(decoratorOnClassMethod6.ts, 0, 25)) ->target : Symbol(target, Decl(decoratorOnClassMethod6.ts, 0, 28)) ->propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethod6.ts, 0, 40)) ->descriptor : Symbol(descriptor, Decl(decoratorOnClassMethod6.ts, 0, 61)) ->TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36)) ->T : Symbol(T, Decl(decoratorOnClassMethod6.ts, 0, 25)) ->TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, 1171, 36)) ->T : Symbol(T, Decl(decoratorOnClassMethod6.ts, 0, 25)) - -class C { ->C : Symbol(C, Decl(decoratorOnClassMethod6.ts, 0, 132)) - - @dec ["method"]() {} ->dec : Symbol(dec, Decl(decoratorOnClassMethod6.ts, 0, 0)) -} diff --git a/tests/baselines/reference/decoratorOnClassMethod6.types b/tests/baselines/reference/decoratorOnClassMethod6.types deleted file mode 100644 index 9da71791763..00000000000 --- a/tests/baselines/reference/decoratorOnClassMethod6.types +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts === -declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; ->dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->T : T ->target : any ->propertyKey : string ->descriptor : TypedPropertyDescriptor ->TypedPropertyDescriptor : TypedPropertyDescriptor ->T : T ->TypedPropertyDescriptor : TypedPropertyDescriptor ->T : T - -class C { ->C : C - - @dec ["method"]() {} ->dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->"method" : string -} diff --git a/tests/baselines/reference/decoratorOnClassMethod8.errors.txt b/tests/baselines/reference/decoratorOnClassMethod8.errors.txt new file mode 100644 index 00000000000..f522dc01df9 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod8.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts(4,5): error TS1241: Unable to resolve signature of method decorator when called as an expression. + Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts (1 errors) ==== + declare function dec(target: T): T; + + class C { + @dec method() {} + ~~~~ +!!! error TS1241: Unable to resolve signature of method decorator when called as an expression. +!!! error TS1241: Supplied parameters do not match any signature of call target. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod8.symbols b/tests/baselines/reference/decoratorOnClassMethod8.symbols deleted file mode 100644 index 84b68b81421..00000000000 --- a/tests/baselines/reference/decoratorOnClassMethod8.symbols +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts === -declare function dec(target: T): T; ->dec : Symbol(dec, Decl(decoratorOnClassMethod8.ts, 0, 0)) ->T : Symbol(T, Decl(decoratorOnClassMethod8.ts, 0, 21)) ->target : Symbol(target, Decl(decoratorOnClassMethod8.ts, 0, 24)) ->T : Symbol(T, Decl(decoratorOnClassMethod8.ts, 0, 21)) ->T : Symbol(T, Decl(decoratorOnClassMethod8.ts, 0, 21)) - -class C { ->C : Symbol(C, Decl(decoratorOnClassMethod8.ts, 0, 38)) - - @dec method() {} ->dec : Symbol(dec, Decl(decoratorOnClassMethod8.ts, 0, 0)) ->method : Symbol(method, Decl(decoratorOnClassMethod8.ts, 2, 9)) -} diff --git a/tests/baselines/reference/decoratorOnClassMethod8.types b/tests/baselines/reference/decoratorOnClassMethod8.types deleted file mode 100644 index 20890b09846..00000000000 --- a/tests/baselines/reference/decoratorOnClassMethod8.types +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts === -declare function dec(target: T): T; ->dec : (target: T) => T ->T : T ->target : T ->T : T ->T : T - -class C { ->C : C - - @dec method() {} ->dec : (target: T) => T ->method : () => void -} diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js index 4a3ed36eec5..a6ab1704acc 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.js +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -1,5 +1,5 @@ //// [decoratorOnClassMethodParameter1.ts] -declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; class C { method(@dec p: number) {} diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.symbols b/tests/baselines/reference/decoratorOnClassMethodParameter1.symbols index 0ced8829766..47c5999ff47 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.symbols +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.symbols @@ -1,13 +1,13 @@ === tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts === -declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; >dec : Symbol(dec, Decl(decoratorOnClassMethodParameter1.ts, 0, 0)) >target : Symbol(target, Decl(decoratorOnClassMethodParameter1.ts, 0, 21)) ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) ->propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodParameter1.ts, 0, 38)) ->parameterIndex : Symbol(parameterIndex, Decl(decoratorOnClassMethodParameter1.ts, 0, 68)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodParameter1.ts, 0, 36)) +>parameterIndex : Symbol(parameterIndex, Decl(decoratorOnClassMethodParameter1.ts, 0, 66)) class C { ->C : Symbol(C, Decl(decoratorOnClassMethodParameter1.ts, 0, 99)) +>C : Symbol(C, Decl(decoratorOnClassMethodParameter1.ts, 0, 97)) method(@dec p: number) {} >method : Symbol(method, Decl(decoratorOnClassMethodParameter1.ts, 2, 9)) diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.types b/tests/baselines/reference/decoratorOnClassMethodParameter1.types index 0b75471471f..74aa04a8985 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.types +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.types @@ -1,8 +1,8 @@ === tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts === -declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; ->dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void ->target : Function ->Function : Function +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; +>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +>target : Object +>Object : Object >propertyKey : string | symbol >parameterIndex : number @@ -11,6 +11,6 @@ class C { method(@dec p: number) {} >method : (p: number) => void ->dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void +>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void >p : number } diff --git a/tests/baselines/reference/decoratorOnClassProperty11.errors.txt b/tests/baselines/reference/decoratorOnClassProperty11.errors.txt new file mode 100644 index 00000000000..6ff700564e8 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty11.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts(4,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts (1 errors) ==== + declare function dec(): (target: any, propertyKey: string) => void; + + class C { + @dec prop; + ~~~~ +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Supplied parameters do not match any signature of call target. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty11.symbols b/tests/baselines/reference/decoratorOnClassProperty11.symbols deleted file mode 100644 index c7d6e39c713..00000000000 --- a/tests/baselines/reference/decoratorOnClassProperty11.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts === -declare function dec(): (target: any, propertyKey: string) => void; ->dec : Symbol(dec, Decl(decoratorOnClassProperty11.ts, 0, 0)) ->T : Symbol(T, Decl(decoratorOnClassProperty11.ts, 0, 25)) ->target : Symbol(target, Decl(decoratorOnClassProperty11.ts, 0, 28)) ->propertyKey : Symbol(propertyKey, Decl(decoratorOnClassProperty11.ts, 0, 40)) - -class C { ->C : Symbol(C, Decl(decoratorOnClassProperty11.ts, 0, 70)) - - @dec prop; ->dec : Symbol(dec, Decl(decoratorOnClassProperty11.ts, 0, 0)) ->prop : Symbol(prop, Decl(decoratorOnClassProperty11.ts, 2, 9)) -} diff --git a/tests/baselines/reference/decoratorOnClassProperty11.types b/tests/baselines/reference/decoratorOnClassProperty11.types deleted file mode 100644 index 5caa467d3ba..00000000000 --- a/tests/baselines/reference/decoratorOnClassProperty11.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts === -declare function dec(): (target: any, propertyKey: string) => void; ->dec : () => (target: any, propertyKey: string) => void ->T : T ->target : any ->propertyKey : string - -class C { ->C : C - - @dec prop; ->dec : () => (target: any, propertyKey: string) => void ->prop : any -} diff --git a/tests/baselines/reference/decoratorOnClassProperty6.errors.txt b/tests/baselines/reference/decoratorOnClassProperty6.errors.txt new file mode 100644 index 00000000000..dbb104e8cd3 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts(4,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts (1 errors) ==== + declare function dec(target: Function): void; + + class C { + @dec prop; + ~~~~ +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Supplied parameters do not match any signature of call target. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty6.symbols b/tests/baselines/reference/decoratorOnClassProperty6.symbols deleted file mode 100644 index 7b9857e0a19..00000000000 --- a/tests/baselines/reference/decoratorOnClassProperty6.symbols +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts === -declare function dec(target: Function): void; ->dec : Symbol(dec, Decl(decoratorOnClassProperty6.ts, 0, 0)) ->target : Symbol(target, Decl(decoratorOnClassProperty6.ts, 0, 21)) ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) - -class C { ->C : Symbol(C, Decl(decoratorOnClassProperty6.ts, 0, 45)) - - @dec prop; ->dec : Symbol(dec, Decl(decoratorOnClassProperty6.ts, 0, 0)) ->prop : Symbol(prop, Decl(decoratorOnClassProperty6.ts, 2, 9)) -} diff --git a/tests/baselines/reference/decoratorOnClassProperty6.types b/tests/baselines/reference/decoratorOnClassProperty6.types deleted file mode 100644 index 59d03678330..00000000000 --- a/tests/baselines/reference/decoratorOnClassProperty6.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts === -declare function dec(target: Function): void; ->dec : (target: Function) => void ->target : Function ->Function : Function - -class C { ->C : C - - @dec prop; ->dec : (target: Function) => void ->prop : any -} diff --git a/tests/baselines/reference/decoratorOnClassProperty7.errors.txt b/tests/baselines/reference/decoratorOnClassProperty7.errors.txt index 8b93d0ab38e..41396acd17e 100644 --- a/tests/baselines/reference/decoratorOnClassProperty7.errors.txt +++ b/tests/baselines/reference/decoratorOnClassProperty7.errors.txt @@ -1,4 +1,5 @@ -tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts (1 errors) ==== @@ -7,5 +8,6 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4 class C { @dec prop; ~~~~ -!!! error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'. +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Supplied parameters do not match any signature of call target. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js index 37dc2db870b..b9090176add 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js @@ -37,8 +37,7 @@ class Derived4 extends Base2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js index eaf7dfd5698..64da47e68e0 100644 --- a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js +++ b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js @@ -18,8 +18,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js index b83255ccf93..0538ba9b54a 100644 --- a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js +++ b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js @@ -44,8 +44,7 @@ var r8 = d2[1]; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js index 1fe59d78044..a575c9bb183 100644 --- a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js +++ b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js @@ -21,8 +21,7 @@ class Derived2 extends Base2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js index b9cd6df0338..7e11209b8fe 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js +++ b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js @@ -19,8 +19,7 @@ new DerivedClass(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var BaseClass = (function () { function BaseClass() { diff --git a/tests/baselines/reference/derivedClassOverridesPrivates.js b/tests/baselines/reference/derivedClassOverridesPrivates.js index 2cc8360a803..6662b5013d8 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivates.js +++ b/tests/baselines/reference/derivedClassOverridesPrivates.js @@ -19,8 +19,7 @@ class Derived2 extends Base2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js index 48ee6eded6c..21f2ce87880 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js @@ -40,8 +40,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x; var y; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js index fca27b0de04..b5fe3e93af5 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js @@ -67,8 +67,7 @@ var r8 = d2[1]; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x; var y; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js index 2a102d55eac..c4dc1d0e9d5 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js @@ -75,8 +75,7 @@ class Derived10 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x; var y; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js index 5145f3919a8..f25c3b792de 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js @@ -18,8 +18,7 @@ class Derived2 extends Derived1 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x; var y; diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.js b/tests/baselines/reference/derivedClassOverridesPublicMembers.js index 0529189e4c1..5125be4eeeb 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.js +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.js @@ -66,8 +66,7 @@ var r8 = d2[1]; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x; var y; diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js index 5cb746bfdd3..9762c88035a 100644 --- a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js @@ -27,8 +27,7 @@ class Derived2 extends Base2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassParameterProperties.js b/tests/baselines/reference/derivedClassParameterProperties.js index dd5b206ecdd..55c0a312b71 100644 --- a/tests/baselines/reference/derivedClassParameterProperties.js +++ b/tests/baselines/reference/derivedClassParameterProperties.js @@ -99,8 +99,7 @@ class Derived10 extends Base2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index d2914cd6949..0c214d42fec 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -36,8 +36,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js index 7c7e9b40cec..a81a092fa54 100644 --- a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js +++ b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js @@ -32,8 +32,7 @@ class Derived4 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(a) { diff --git a/tests/baselines/reference/derivedClassTransitivity.js b/tests/baselines/reference/derivedClassTransitivity.js index ad4f3e481a7..de7669a71b5 100644 --- a/tests/baselines/reference/derivedClassTransitivity.js +++ b/tests/baselines/reference/derivedClassTransitivity.js @@ -25,8 +25,7 @@ var r2 = e.foo(''); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/derivedClassTransitivity2.js b/tests/baselines/reference/derivedClassTransitivity2.js index efeb25195ff..22e930ab7f9 100644 --- a/tests/baselines/reference/derivedClassTransitivity2.js +++ b/tests/baselines/reference/derivedClassTransitivity2.js @@ -25,8 +25,7 @@ var r2 = e.foo(1, ''); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/derivedClassTransitivity3.js b/tests/baselines/reference/derivedClassTransitivity3.js index 8befbf18731..a1aa3a978eb 100644 --- a/tests/baselines/reference/derivedClassTransitivity3.js +++ b/tests/baselines/reference/derivedClassTransitivity3.js @@ -25,8 +25,7 @@ var r2 = e.foo('', 1); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/derivedClassTransitivity4.js b/tests/baselines/reference/derivedClassTransitivity4.js index 546c7e4a849..a4d319707c7 100644 --- a/tests/baselines/reference/derivedClassTransitivity4.js +++ b/tests/baselines/reference/derivedClassTransitivity4.js @@ -25,8 +25,7 @@ var r2 = e.foo(''); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/derivedClassWithAny.js b/tests/baselines/reference/derivedClassWithAny.js index 6f9ef484627..123853f3afd 100644 --- a/tests/baselines/reference/derivedClassWithAny.js +++ b/tests/baselines/reference/derivedClassWithAny.js @@ -63,8 +63,7 @@ var r = c.foo(); // e.foo would return string var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js index bf8b1b51cd1..3454c60f881 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js @@ -26,8 +26,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js index 131c529f3bf..7de92c9cb2f 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js @@ -36,8 +36,7 @@ Derived.a = 2; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js index d661eeadc06..36d2b7d2dc3 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js @@ -25,8 +25,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js index c3fc34b21c1..36080385b3b 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js @@ -37,8 +37,7 @@ Derived.a = 2; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js index 16b9b110a5f..27a634ab2d9 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js @@ -29,8 +29,7 @@ var d2 = new D(new Date()); // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js index 6e413752f1d..82c5eec1d7d 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js @@ -37,8 +37,7 @@ var d4 = new D(new Date(), new Date(), new Date()); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js index b72fdb1503d..4bfa7c81577 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js @@ -51,8 +51,7 @@ var d3 = new D2(new Date(), new Date()); // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/derivedClasses.js b/tests/baselines/reference/derivedClasses.js index 7221031cb8b..214c65bde6c 100644 --- a/tests/baselines/reference/derivedClasses.js +++ b/tests/baselines/reference/derivedClasses.js @@ -34,8 +34,7 @@ b.hue(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Red = (function (_super) { __extends(Red, _super); diff --git a/tests/baselines/reference/derivedGenericClassWithAny.js b/tests/baselines/reference/derivedGenericClassWithAny.js index b5bfbd5e5db..15835e78bd5 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.js +++ b/tests/baselines/reference/derivedGenericClassWithAny.js @@ -46,8 +46,7 @@ var r = c.foo(); // e.foo would return string var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js index 564a51f2b13..0839b93971b 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js @@ -21,8 +21,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js index f981a5e6e54..f00c32114cf 100644 --- a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js +++ b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js @@ -24,8 +24,7 @@ var r: Base[] = [d1, d2]; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.js b/tests/baselines/reference/destructuringParameterDeclaration5.js index 7540302599c..38366ca67ba 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration5.js +++ b/tests/baselines/reference/destructuringParameterDeclaration5.js @@ -55,8 +55,7 @@ d3({ y: "world" }); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Class = (function () { function Class() { diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types index 0f546fa7b86..e469a377985 100644 --- a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types @@ -9,11 +9,11 @@ class B { } class C extends B { } >C : C ->B : B +>B : B class D extends B { >D : D ->B : B +>B : B constructor(a: any) >a : any diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.js b/tests/baselines/reference/emitThisInSuperMethodCall.js index 9224e156de9..f5cff5a8fa5 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.js +++ b/tests/baselines/reference/emitThisInSuperMethodCall.js @@ -31,8 +31,7 @@ class RegisteredUser extends User { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var User = (function () { function User() { diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js new file mode 100644 index 00000000000..05b59b7d5f2 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js @@ -0,0 +1,11 @@ +//// [emptyArrayBindingPatternParameter01.ts] + + +function f([]) { + var x, y, z; +} + +//// [emptyArrayBindingPatternParameter01.js] +function f(_a) { + var x, y, z; +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols new file mode 100644 index 00000000000..3207ca97dec --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts === + + +function f([]) { +>f : Symbol(f, Decl(emptyArrayBindingPatternParameter01.ts, 0, 0)) + + var x, y, z; +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 4)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10)) +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types new file mode 100644 index 00000000000..e93394b7371 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts === + + +function f([]) { +>f : ([]: any[]) => void + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.js b/tests/baselines/reference/emptyArrayBindingPatternParameter02.js new file mode 100644 index 00000000000..dbd86e843a8 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.js @@ -0,0 +1,11 @@ +//// [emptyArrayBindingPatternParameter02.ts] + + +function f(a, []) { + var x, y, z; +} + +//// [emptyArrayBindingPatternParameter02.js] +function f(a, _a) { + var x, y, z; +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols new file mode 100644 index 00000000000..48cdcfaf93d --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts === + + +function f(a, []) { +>f : Symbol(f, Decl(emptyArrayBindingPatternParameter02.ts, 0, 0)) +>a : Symbol(a, Decl(emptyArrayBindingPatternParameter02.ts, 2, 11)) + + var x, y, z; +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter02.ts, 3, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter02.ts, 3, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter02.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.types b/tests/baselines/reference/emptyArrayBindingPatternParameter02.types new file mode 100644 index 00000000000..a58fe6b91d3 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts === + + +function f(a, []) { +>f : (a: any, []: any[]) => void +>a : any + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.js b/tests/baselines/reference/emptyArrayBindingPatternParameter03.js new file mode 100644 index 00000000000..e2c3f7196e6 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.js @@ -0,0 +1,11 @@ +//// [emptyArrayBindingPatternParameter03.ts] + + +function f(a, []) { + var x, y, z; +} + +//// [emptyArrayBindingPatternParameter03.js] +function f(a, _a) { + var x, y, z; +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols new file mode 100644 index 00000000000..d3ec078df78 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts === + + +function f(a, []) { +>f : Symbol(f, Decl(emptyArrayBindingPatternParameter03.ts, 0, 0)) +>a : Symbol(a, Decl(emptyArrayBindingPatternParameter03.ts, 2, 11)) + + var x, y, z; +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter03.ts, 3, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter03.ts, 3, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter03.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.types b/tests/baselines/reference/emptyArrayBindingPatternParameter03.types new file mode 100644 index 00000000000..43f0af63ace --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts === + + +function f(a, []) { +>f : (a: any, []: any[]) => void +>a : any + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.js b/tests/baselines/reference/emptyArrayBindingPatternParameter04.js new file mode 100644 index 00000000000..e0715499ffe --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.js @@ -0,0 +1,12 @@ +//// [emptyArrayBindingPatternParameter04.ts] + + +function f([] = [1,2,3,4]) { + var x, y, z; +} + +//// [emptyArrayBindingPatternParameter04.js] +function f(_a) { + var _a = [1, 2, 3, 4]; + var x, y, z; +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols new file mode 100644 index 00000000000..bb76a2c5925 --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts === + + +function f([] = [1,2,3,4]) { +>f : Symbol(f, Decl(emptyArrayBindingPatternParameter04.ts, 0, 0)) + + var x, y, z; +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter04.ts, 3, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter04.ts, 3, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter04.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types new file mode 100644 index 00000000000..6f00a994f7b --- /dev/null +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts === + + +function f([] = [1,2,3,4]) { +>f : ([]?: number[]) => void +>[1,2,3,4] : number[] +>1 : number +>2 : number +>3 : number +>4 : number + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.js b/tests/baselines/reference/emptyObjectBindingPatternParameter01.js new file mode 100644 index 00000000000..28cc30d2a0b --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.js @@ -0,0 +1,11 @@ +//// [emptyObjectBindingPatternParameter01.ts] + + +function f({}) { + var x, y, z; +} + +//// [emptyObjectBindingPatternParameter01.js] +function f(_a) { + var x, y, z; +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols new file mode 100644 index 00000000000..98829df994f --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts === + + +function f({}) { +>f : Symbol(f, Decl(emptyObjectBindingPatternParameter01.ts, 0, 0)) + + var x, y, z; +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter01.ts, 3, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter01.ts, 3, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter01.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.types b/tests/baselines/reference/emptyObjectBindingPatternParameter01.types new file mode 100644 index 00000000000..c46569ea770 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts === + + +function f({}) { +>f : ({}: {}) => void + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.js b/tests/baselines/reference/emptyObjectBindingPatternParameter02.js new file mode 100644 index 00000000000..8488428ea51 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.js @@ -0,0 +1,11 @@ +//// [emptyObjectBindingPatternParameter02.ts] + + +function f(a, {}) { + var x, y, z; +} + +//// [emptyObjectBindingPatternParameter02.js] +function f(a, _a) { + var x, y, z; +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols new file mode 100644 index 00000000000..fb0fa946b6f --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts === + + +function f(a, {}) { +>f : Symbol(f, Decl(emptyObjectBindingPatternParameter02.ts, 0, 0)) +>a : Symbol(a, Decl(emptyObjectBindingPatternParameter02.ts, 2, 11)) + + var x, y, z; +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter02.ts, 3, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter02.ts, 3, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter02.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.types b/tests/baselines/reference/emptyObjectBindingPatternParameter02.types new file mode 100644 index 00000000000..0a77fac8588 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts === + + +function f(a, {}) { +>f : (a: any, {}: {}) => void +>a : any + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.js b/tests/baselines/reference/emptyObjectBindingPatternParameter03.js new file mode 100644 index 00000000000..0279744e386 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.js @@ -0,0 +1,11 @@ +//// [emptyObjectBindingPatternParameter03.ts] + + +function f({}, a) { + var x, y, z; +} + +//// [emptyObjectBindingPatternParameter03.js] +function f(_a, a) { + var x, y, z; +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols new file mode 100644 index 00000000000..4e658e21ccf --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts === + + +function f({}, a) { +>f : Symbol(f, Decl(emptyObjectBindingPatternParameter03.ts, 0, 0)) +>a : Symbol(a, Decl(emptyObjectBindingPatternParameter03.ts, 2, 14)) + + var x, y, z; +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter03.ts, 3, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter03.ts, 3, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter03.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.types b/tests/baselines/reference/emptyObjectBindingPatternParameter03.types new file mode 100644 index 00000000000..873c748dd9b --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts === + + +function f({}, a) { +>f : ({}: {}, a: any) => void +>a : any + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.js b/tests/baselines/reference/emptyObjectBindingPatternParameter04.js new file mode 100644 index 00000000000..fc3e41d0709 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.js @@ -0,0 +1,12 @@ +//// [emptyObjectBindingPatternParameter04.ts] + + +function f({} = {a: 1, b: "2", c: true}) { + var x, y, z; +} + +//// [emptyObjectBindingPatternParameter04.js] +function f(_a) { + var _a = { a: 1, b: "2", c: true }; + var x, y, z; +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols new file mode 100644 index 00000000000..9922d4cd074 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts === + + +function f({} = {a: 1, b: "2", c: true}) { +>f : Symbol(f, Decl(emptyObjectBindingPatternParameter04.ts, 0, 0)) +>a : Symbol(a, Decl(emptyObjectBindingPatternParameter04.ts, 2, 17)) +>b : Symbol(b, Decl(emptyObjectBindingPatternParameter04.ts, 2, 22)) +>c : Symbol(c, Decl(emptyObjectBindingPatternParameter04.ts, 2, 30)) + + var x, y, z; +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter04.ts, 3, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter04.ts, 3, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter04.ts, 3, 13)) +} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.types b/tests/baselines/reference/emptyObjectBindingPatternParameter04.types new file mode 100644 index 00000000000..5ee32d422a9 --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts === + + +function f({} = {a: 1, b: "2", c: true}) { +>f : ({}?: { a: number; b: string; c: boolean; }) => void +>{a: 1, b: "2", c: true} : { a: number; b: string; c: boolean; } +>a : number +>1 : number +>b : string +>"2" : string +>c : boolean +>true : boolean + + var x, y, z; +>x : any +>y : any +>z : any +} diff --git a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js index f1a0d741a5c..0b30745fa15 100644 --- a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js +++ b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js @@ -15,8 +15,7 @@ class derived extends base { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function f() { var d1 = new derived(); diff --git a/tests/baselines/reference/errorSuperCalls.js b/tests/baselines/reference/errorSuperCalls.js index bd692f35fa3..d2d4911c76a 100644 --- a/tests/baselines/reference/errorSuperCalls.js +++ b/tests/baselines/reference/errorSuperCalls.js @@ -78,8 +78,7 @@ class OtherDerived extends OtherBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; //super call in class constructor with no base type var NoBase = (function () { diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index abf077d2b82..57a574d8a06 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -132,8 +132,7 @@ var obj = { n: super.wat, p: super.foo() }; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; //super property access in constructor of class with no base type //super property access in instance member function of class with no base type diff --git a/tests/baselines/reference/errorsInGenericTypeReference.js b/tests/baselines/reference/errorsInGenericTypeReference.js index 0ba69b601ae..42c7456be60 100644 --- a/tests/baselines/reference/errorsInGenericTypeReference.js +++ b/tests/baselines/reference/errorsInGenericTypeReference.js @@ -76,8 +76,7 @@ interface testInterface2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.js b/tests/baselines/reference/es6ClassSuperCodegenBug.js index a374778ef45..62c96f6260d 100644 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.js +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.js @@ -17,8 +17,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(str1, str2) { diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js index bf65840e31c..9247dfde1c3 100644 --- a/tests/baselines/reference/es6ClassTest.js +++ b/tests/baselines/reference/es6ClassTest.js @@ -88,8 +88,7 @@ declare module AmbientMod { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Bar = (function () { function Bar(n) { diff --git a/tests/baselines/reference/es6ClassTest2.js b/tests/baselines/reference/es6ClassTest2.js index 40f1c15c8f1..20200a692ff 100644 --- a/tests/baselines/reference/es6ClassTest2.js +++ b/tests/baselines/reference/es6ClassTest2.js @@ -162,8 +162,7 @@ var ccwc = new ChildClassWithoutConstructor(1, "s"); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var BasicMonster = (function () { function BasicMonster(name, health) { diff --git a/tests/baselines/reference/es6ClassTest7.js b/tests/baselines/reference/es6ClassTest7.js index c4f7e83b9a2..970e9c4fd9e 100644 --- a/tests/baselines/reference/es6ClassTest7.js +++ b/tests/baselines/reference/es6ClassTest7.js @@ -12,8 +12,7 @@ class Bar extends M.Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Bar = (function (_super) { __extends(Bar, _super); diff --git a/tests/baselines/reference/es6ClassTest7.types b/tests/baselines/reference/es6ClassTest7.types index f92ddad6e82..c0399204ffa 100644 --- a/tests/baselines/reference/es6ClassTest7.types +++ b/tests/baselines/reference/es6ClassTest7.types @@ -9,8 +9,8 @@ declare module M { class Bar extends M.Foo { >Bar : Bar ->M.Foo : any +>M.Foo : M.Foo >M : typeof M ->Foo : M.Foo +>Foo : typeof M.Foo } diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types index 9d87ec9925d..6b621f4c777 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -31,8 +31,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof m +>instantiatedModule : typeof m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 9d87ec9925d..6b621f4c777 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -31,8 +31,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof m +>instantiatedModule : typeof m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/exportAssignNonIdentifier.errors.txt b/tests/baselines/reference/exportAssignNonIdentifier.errors.txt index 09e86ec12c4..c3d58c9b36f 100644 --- a/tests/baselines/reference/exportAssignNonIdentifier.errors.txt +++ b/tests/baselines/reference/exportAssignNonIdentifier.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/externalModules/foo1.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. -tests/cases/conformance/externalModules/foo3.ts(1,16): error TS9003: 'class' expressions are not currently supported. tests/cases/conformance/externalModules/foo6.ts(1,14): error TS1109: Expression expected. @@ -12,10 +11,8 @@ tests/cases/conformance/externalModules/foo6.ts(1,14): error TS1109: Expression ==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ==== export = "sausages"; // Ok -==== tests/cases/conformance/externalModules/foo3.ts (1 errors) ==== +==== tests/cases/conformance/externalModules/foo3.ts (0 errors) ==== export = class Foo3 {}; // Error, not an expression - ~~~~ -!!! error TS9003: 'class' expressions are not currently supported. ==== tests/cases/conformance/externalModules/foo4.ts (0 errors) ==== export = true; // Ok diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.js b/tests/baselines/reference/exportAssignmentOfGenericType1.js index 983c328cd98..59fa01f2ca0 100644 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.js +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.js @@ -26,8 +26,7 @@ define(["require", "exports"], function (require, exports) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; define(["require", "exports", "exportAssignmentOfGenericType1_0"], function (require, exports, q) { var M = (function (_super) { diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.types b/tests/baselines/reference/exportAssignmentOfGenericType1.types index 1bf3e7454a7..06ff38b2623 100644 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.types +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.types @@ -5,7 +5,7 @@ import q = require("exportAssignmentOfGenericType1_0"); class M extends q { } >M : M ->q : q +>q : q var m: M; >m : M diff --git a/tests/baselines/reference/exportDeclarationInInternalModule.js b/tests/baselines/reference/exportDeclarationInInternalModule.js index 9894f1fb194..4a1ee9b739f 100644 --- a/tests/baselines/reference/exportDeclarationInInternalModule.js +++ b/tests/baselines/reference/exportDeclarationInInternalModule.js @@ -22,8 +22,7 @@ var a: Bbb.SomeType; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Bbb = (function () { function Bbb() { diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js new file mode 100644 index 00000000000..3fc40121011 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js @@ -0,0 +1,15 @@ +//// [exportSpecifierAndExportedMemberDeclaration.ts] +declare module "m2" { + export module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} + +//// [exportSpecifierAndExportedMemberDeclaration.js] diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols new file mode 100644 index 00000000000..7e2de735c47 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === +declare module "m2" { + export module X { +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) + + interface I { } +>I : Symbol(I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) + } + function Y(); +>Y : Symbol(Y, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 3, 5)) + + export { Y as X }; +>Y : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) + + function Z(): X.I; +>Z : Symbol(Z, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 22)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>I : Symbol(X.I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) +} + +declare module "m2" { + function Z2(): X.I; +>Z2 : Symbol(Z2, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 9, 21)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>I : Symbol(X.I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) +} diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types new file mode 100644 index 00000000000..931552819c7 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === +declare module "m2" { + export module X { +>X : () => any + + interface I { } +>I : I + } + function Y(); +>Y : () => any + + export { Y as X }; +>Y : () => any +>X : () => any + + function Z(): X.I; +>Z : () => X.I +>X : any +>I : X.I +} + +declare module "m2" { + function Z2(): X.I; +>Z2 : () => X.I +>X : any +>I : X.I +} diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt new file mode 100644 index 00000000000..eb444919f2c --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts(11,20): error TS2503: Cannot find namespace 'X'. + + +==== tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts (1 errors) ==== + declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; + } + + declare module "m2" { + function Z2(): X.I; + ~ +!!! error TS2503: Cannot find namespace 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js new file mode 100644 index 00000000000..d99ff3627ed --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js @@ -0,0 +1,15 @@ +//// [exportSpecifierAndLocalMemberDeclaration.ts] +declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} + +//// [exportSpecifierAndLocalMemberDeclaration.js] diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.js b/tests/baselines/reference/exportSpecifierForAGlobal.js new file mode 100644 index 00000000000..6b4343a299b --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/exportSpecifierForAGlobal.ts] //// + +//// [a.d.ts] + +declare class X { } + +//// [b.ts] +export {X}; +export function f() { + var x: X; + return x; +} + + +//// [b.js] +function f() { + var x; + return x; +} +exports.f = f; + + +//// [b.d.ts] +export { X }; +export declare function f(): X; diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.symbols b/tests/baselines/reference/exportSpecifierForAGlobal.symbols new file mode 100644 index 00000000000..b38fc7be270 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.d.ts === + +declare class X { } +>X : Symbol(X, Decl(a.d.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +export {X}; +>X : Symbol(X, Decl(b.ts, 0, 8)) + +export function f() { +>f : Symbol(f, Decl(b.ts, 0, 11)) + + var x: X; +>x : Symbol(x, Decl(b.ts, 2, 7)) +>X : Symbol(X, Decl(a.d.ts, 0, 0)) + + return x; +>x : Symbol(x, Decl(b.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.types b/tests/baselines/reference/exportSpecifierForAGlobal.types new file mode 100644 index 00000000000..e3d728ad0d0 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.d.ts === + +declare class X { } +>X : X + +=== tests/cases/compiler/b.ts === +export {X}; +>X : typeof X + +export function f() { +>f : () => X + + var x: X; +>x : X +>X : X + + return x; +>x : X +} + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js new file mode 100644 index 00000000000..003956e2822 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js @@ -0,0 +1,8 @@ +//// [exportSpecifierReferencingOuterDeclaration1.ts] +declare module X { export interface bar { } } +declare module "m" { + export { X }; + export function foo(): X.bar; +} + +//// [exportSpecifierReferencingOuterDeclaration1.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols new file mode 100644 index 00000000000..16abde86d32 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === +declare module X { export interface bar { } } +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) +>bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) + +declare module "m" { + export { X }; +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 12)) + + export function foo(): X.bar; +>foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 17)) +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) +>bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) +} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types new file mode 100644 index 00000000000..be03554a1b0 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === +declare module X { export interface bar { } } +>X : any +>bar : bar + +declare module "m" { + export { X }; +>X : any + + export function foo(): X.bar; +>foo : () => X.bar +>X : any +>bar : X.bar +} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js new file mode 100644 index 00000000000..e8e96784083 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts] //// + +//// [exportSpecifierReferencingOuterDeclaration2_A.ts] +declare module X { export interface bar { } } + +//// [exportSpecifierReferencingOuterDeclaration2_B.ts] +export { X }; +export declare function foo(): X.bar; + +//// [exportSpecifierReferencingOuterDeclaration2_A.js] +//// [exportSpecifierReferencingOuterDeclaration2_B.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols new file mode 100644 index 00000000000..9a57645b1cb --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === +declare module X { export interface bar { } } +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) +>bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) + +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === +export { X }; +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 8)) + +export declare function foo(): X.bar; +>foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 13)) +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) +>bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types new file mode 100644 index 00000000000..fa59948c116 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === +declare module X { export interface bar { } } +>X : any +>bar : bar + +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === +export { X }; +>X : any + +export declare function foo(): X.bar; +>foo : () => X.bar +>X : any +>bar : X.bar + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt new file mode 100644 index 00000000000..e144c48bea4 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts(6,30): error TS2305: Module 'X' has no exported member 'bar'. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts (1 errors) ==== + declare module X { export interface bar { } } + declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error + ~~~ +!!! error TS2305: Module 'X' has no exported member 'bar'. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js new file mode 100644 index 00000000000..0f6fff977da --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js @@ -0,0 +1,10 @@ +//// [exportSpecifierReferencingOuterDeclaration3.ts] +declare module X { export interface bar { } } +declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error +} + +//// [exportSpecifierReferencingOuterDeclaration3.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt new file mode 100644 index 00000000000..6ac67c70d17 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(4,34): error TS2305: Module 'X' has no exported member 'bar'. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts (0 errors) ==== + declare module X { export interface bar { } } + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts (1 errors) ==== + declare module X { export interface foo { } } + export { X }; + export declare function foo(): X.foo; + export declare function bar(): X.bar; // error + ~~~ +!!! error TS2305: Module 'X' has no exported member 'bar'. \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js new file mode 100644 index 00000000000..4edb5f711a6 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts] //// + +//// [exportSpecifierReferencingOuterDeclaration2_A.ts] +declare module X { export interface bar { } } + +//// [exportSpecifierReferencingOuterDeclaration2_B.ts] +declare module X { export interface foo { } } +export { X }; +export declare function foo(): X.foo; +export declare function bar(): X.bar; // error + +//// [exportSpecifierReferencingOuterDeclaration2_A.js] +//// [exportSpecifierReferencingOuterDeclaration2_B.js] diff --git a/tests/baselines/reference/exportsAndImports3-amd.symbols b/tests/baselines/reference/exportsAndImports3-amd.symbols index 4ab418a9bef..a46d7df2a68 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.symbols +++ b/tests/baselines/reference/exportsAndImports3-amd.symbols @@ -16,17 +16,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 6, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 7, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 8, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 8, 9)) +>A : Symbol(E.A, Decl(t1.ts, 7, 15)) +>B : Symbol(E.B, Decl(t1.ts, 8, 6)) +>C : Symbol(E.C, Decl(t1.ts, 8, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 9, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 10, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 11, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 11, 9)) +>A : Symbol(D.A, Decl(t1.ts, 10, 21)) +>B : Symbol(D.B, Decl(t1.ts, 11, 6)) +>C : Symbol(D.C, Decl(t1.ts, 11, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 12, 1)) diff --git a/tests/baselines/reference/exportsAndImports3.symbols b/tests/baselines/reference/exportsAndImports3.symbols index 4ab418a9bef..a46d7df2a68 100644 --- a/tests/baselines/reference/exportsAndImports3.symbols +++ b/tests/baselines/reference/exportsAndImports3.symbols @@ -16,17 +16,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 6, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 7, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 8, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 8, 9)) +>A : Symbol(E.A, Decl(t1.ts, 7, 15)) +>B : Symbol(E.B, Decl(t1.ts, 8, 6)) +>C : Symbol(E.C, Decl(t1.ts, 8, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 9, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 10, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 11, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 11, 9)) +>A : Symbol(D.A, Decl(t1.ts, 10, 21)) +>B : Symbol(D.B, Decl(t1.ts, 11, 6)) +>C : Symbol(D.C, Decl(t1.ts, 11, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 12, 1)) diff --git a/tests/baselines/reference/extBaseClass1.js b/tests/baselines/reference/extBaseClass1.js index 9e7421b906c..07923eccc88 100644 --- a/tests/baselines/reference/extBaseClass1.js +++ b/tests/baselines/reference/extBaseClass1.js @@ -23,8 +23,7 @@ module N { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/extBaseClass1.types b/tests/baselines/reference/extBaseClass1.types index b476e1b4206..1ab2ec3ba53 100644 --- a/tests/baselines/reference/extBaseClass1.types +++ b/tests/baselines/reference/extBaseClass1.types @@ -30,9 +30,9 @@ module N { export class C3 extends M.B { >C3 : C3 ->M.B : any +>M.B : M.B >M : typeof M ->B : M.B +>B : typeof M.B } } diff --git a/tests/baselines/reference/extBaseClass2.errors.txt b/tests/baselines/reference/extBaseClass2.errors.txt index 10c406b6ba0..b4d243c7ef2 100644 --- a/tests/baselines/reference/extBaseClass2.errors.txt +++ b/tests/baselines/reference/extBaseClass2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/extBaseClass2.ts(2,31): error TS2305: Module 'M' has no exported member 'B'. +tests/cases/compiler/extBaseClass2.ts(2,31): error TS2339: Property 'B' does not exist on type 'typeof M'. tests/cases/compiler/extBaseClass2.ts(7,29): error TS2304: Cannot find name 'B'. @@ -6,7 +6,7 @@ tests/cases/compiler/extBaseClass2.ts(7,29): error TS2304: Cannot find name 'B'. module N { export class C4 extends M.B { ~ -!!! error TS2305: Module 'M' has no exported member 'B'. +!!! error TS2339: Property 'B' does not exist on type 'typeof M'. } } diff --git a/tests/baselines/reference/extBaseClass2.js b/tests/baselines/reference/extBaseClass2.js index e5a717bca80..6e9972c3f29 100644 --- a/tests/baselines/reference/extBaseClass2.js +++ b/tests/baselines/reference/extBaseClass2.js @@ -14,8 +14,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var N; (function (N) { diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType.js b/tests/baselines/reference/extendAndImplementTheSameBaseType.js index c69315dbd61..6a631ceebf8 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType.js @@ -17,8 +17,7 @@ d.foo; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js index 06ea74880c2..42cf785c0b0 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js @@ -20,8 +20,7 @@ var r4: number = d.bar(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js index 7598d771bac..d8c54b58d7e 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js @@ -7,8 +7,7 @@ class base { constructor (public n: number) { } } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var derived = (function (_super) { __extends(derived, _super); diff --git a/tests/baselines/reference/extendNonClassSymbol1.errors.txt b/tests/baselines/reference/extendNonClassSymbol1.errors.txt deleted file mode 100644 index 587ac3a5f04..00000000000 --- a/tests/baselines/reference/extendNonClassSymbol1.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/extendNonClassSymbol1.ts(3,17): error TS2304: Cannot find name 'x'. - - -==== tests/cases/compiler/extendNonClassSymbol1.ts (1 errors) ==== - class A { foo() { } } - var x = A; - class C extends x { } // error, could not find symbol xs - ~ -!!! error TS2304: Cannot find name 'x'. \ No newline at end of file diff --git a/tests/baselines/reference/extendNonClassSymbol1.js b/tests/baselines/reference/extendNonClassSymbol1.js index 59da2d7ca2b..29408686068 100644 --- a/tests/baselines/reference/extendNonClassSymbol1.js +++ b/tests/baselines/reference/extendNonClassSymbol1.js @@ -7,8 +7,7 @@ class C extends x { } // error, could not find symbol xs var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/extendNonClassSymbol1.symbols b/tests/baselines/reference/extendNonClassSymbol1.symbols new file mode 100644 index 00000000000..02291ebb181 --- /dev/null +++ b/tests/baselines/reference/extendNonClassSymbol1.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/extendNonClassSymbol1.ts === +class A { foo() { } } +>A : Symbol(A, Decl(extendNonClassSymbol1.ts, 0, 0)) +>foo : Symbol(foo, Decl(extendNonClassSymbol1.ts, 0, 9)) + +var x = A; +>x : Symbol(x, Decl(extendNonClassSymbol1.ts, 1, 3)) +>A : Symbol(A, Decl(extendNonClassSymbol1.ts, 0, 0)) + +class C extends x { } // error, could not find symbol xs +>C : Symbol(C, Decl(extendNonClassSymbol1.ts, 1, 10)) + diff --git a/tests/baselines/reference/extendNonClassSymbol1.types b/tests/baselines/reference/extendNonClassSymbol1.types new file mode 100644 index 00000000000..72ae7b4566c --- /dev/null +++ b/tests/baselines/reference/extendNonClassSymbol1.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/extendNonClassSymbol1.ts === +class A { foo() { } } +>A : A +>foo : () => void + +var x = A; +>x : typeof A +>A : typeof A + +class C extends x { } // error, could not find symbol xs +>C : C +>x : A + diff --git a/tests/baselines/reference/extendNonClassSymbol2.errors.txt b/tests/baselines/reference/extendNonClassSymbol2.errors.txt index 1b54474ac39..5554ff60a26 100644 --- a/tests/baselines/reference/extendNonClassSymbol2.errors.txt +++ b/tests/baselines/reference/extendNonClassSymbol2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/extendNonClassSymbol2.ts(5,17): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/extendNonClassSymbol2.ts(5,17): error TS2507: Type '() => void' is not a constructor function type. ==== tests/cases/compiler/extendNonClassSymbol2.ts (1 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/extendNonClassSymbol2.ts(5,17): error TS2304: Cannot find n var x = new Foo(); // legal, considered a constructor function class C extends Foo {} // error, could not find symbol Foo ~~~ -!!! error TS2304: Cannot find name 'Foo'. \ No newline at end of file +!!! error TS2507: Type '() => void' is not a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/extendNonClassSymbol2.js b/tests/baselines/reference/extendNonClassSymbol2.js index 830994e3d26..a65eeca612a 100644 --- a/tests/baselines/reference/extendNonClassSymbol2.js +++ b/tests/baselines/reference/extendNonClassSymbol2.js @@ -9,8 +9,7 @@ class C extends Foo {} // error, could not find symbol Foo var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function Foo() { this.x = 1; diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js index 0bf86390b74..297a7527ec0 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js @@ -43,8 +43,7 @@ exports.Model = Model; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { @@ -59,8 +58,7 @@ exports.VisualizationModel = VisualizationModel; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types index 5b9154516c5..b5323ae5c85 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types @@ -61,9 +61,9 @@ import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } @@ -74,9 +74,9 @@ import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // different interesting stuff here } diff --git a/tests/baselines/reference/extendsClauseAlreadySeen.js b/tests/baselines/reference/extendsClauseAlreadySeen.js index 3e7151b8e0d..ed6602c116a 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen.js @@ -10,8 +10,7 @@ class D extends C extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/extendsClauseAlreadySeen2.js b/tests/baselines/reference/extendsClauseAlreadySeen2.js index 9ee428c36ed..2c77f4e673f 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen2.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen2.js @@ -10,8 +10,7 @@ class D extends C extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/for-inStatements.js b/tests/baselines/reference/for-inStatements.js index 749c7b47b34..d735a37ba97 100644 --- a/tests/baselines/reference/for-inStatements.js +++ b/tests/baselines/reference/for-inStatements.js @@ -84,8 +84,7 @@ for (var x in Color.Blue) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var aString; for (aString in {}) { } diff --git a/tests/baselines/reference/for-inStatementsInvalid.js b/tests/baselines/reference/for-inStatementsInvalid.js index e1806272790..93b9fb9b97f 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.js +++ b/tests/baselines/reference/for-inStatementsInvalid.js @@ -67,8 +67,7 @@ for (var x in i[42]) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var aNumber; for (aNumber in {}) { } diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 09d3b036829..a726b7eedc2 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index d4958740698..11ff91e1162 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index 3ab18252114..f6619ff753d 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 3f746c05206..1d447ea87cc 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index e96abcae76e..6b8012c7929 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js index b00e8acef14..1dde9981880 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js @@ -57,8 +57,7 @@ for( var m = M.A;;){} var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/functionImplementationErrors.js b/tests/baselines/reference/functionImplementationErrors.js index 6c1daffdaf1..42be5f21458 100644 --- a/tests/baselines/reference/functionImplementationErrors.js +++ b/tests/baselines/reference/functionImplementationErrors.js @@ -77,8 +77,7 @@ var f13 = () => { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { diff --git a/tests/baselines/reference/functionImplementations.js b/tests/baselines/reference/functionImplementations.js index 0370c4c0027..3fc040650e4 100644 --- a/tests/baselines/reference/functionImplementations.js +++ b/tests/baselines/reference/functionImplementations.js @@ -160,8 +160,7 @@ var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherC var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // FunctionExpression with no return type annotation and no return statement returns void var v = function () { }(); diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs.js b/tests/baselines/reference/functionSubtypingOfVarArgs.js index b0168975677..ddcb0570908 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs.js @@ -18,8 +18,7 @@ class StringEvent extends EventBase { // should work var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var EventBase = (function () { function EventBase() { diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.js b/tests/baselines/reference/functionSubtypingOfVarArgs2.js index 7efd35cc2d2..d04a5b97dae 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.js @@ -18,8 +18,7 @@ class StringEvent extends EventBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var EventBase = (function () { function EventBase() { diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index 3c2c704ddb0..1f7d2b8035f 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -358,8 +358,7 @@ var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/generatorTypeCheck40.errors.txt b/tests/baselines/reference/generatorTypeCheck40.errors.txt index 9d9676e5d28..ba93862c8d5 100644 --- a/tests/baselines/reference/generatorTypeCheck40.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck40.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,21): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,21): error TS2507: Type 'any' is not a constructor function type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,22): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts (2 errors) ==== function* g() { class C extends (yield 0) { } ~~~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Type 'any' is not a constructor function type. + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator body. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck55.errors.txt b/tests/baselines/reference/generatorTypeCheck55.errors.txt index 0846d1c28ad..854c1801efd 100644 --- a/tests/baselines/reference/generatorTypeCheck55.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck55.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck55.ts(2,19): error TS9003: 'class' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck55.ts(2,29): error TS2507: Type 'any' is not a constructor function type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck55.ts(2,30): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck55.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck55.ts (2 errors) ==== function* g() { var x = class C extends (yield) {}; - ~ -!!! error TS9003: 'class' expressions are not currently supported. + ~~~~~~~ +!!! error TS2507: Type 'any' is not a constructor function type. + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator body. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck56.errors.txt b/tests/baselines/reference/generatorTypeCheck56.errors.txt index 99e3b00de41..20961935807 100644 --- a/tests/baselines/reference/generatorTypeCheck56.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck56.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts(2,19): error TS9003: 'class' expressions are not currently supported. tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts (1 errors) ==== function* g() { var x = class C { - ~ -!!! error TS9003: 'class' expressions are not currently supported. *[yield 0]() { ~~~~~ !!! error TS1163: A 'yield' expression is only allowed in a generator body. diff --git a/tests/baselines/reference/generatorTypeCheck60.errors.txt b/tests/baselines/reference/generatorTypeCheck60.errors.txt index d8e5d640bb1..5330cd186b7 100644 --- a/tests/baselines/reference/generatorTypeCheck60.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck60.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts(2,21): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts(2,21): error TS2507: Type 'any' is not a constructor function type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts(2,22): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts (2 errors) ==== function* g() { class C extends (yield) {}; ~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Type 'any' is not a constructor function type. + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator body. } \ No newline at end of file diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.js b/tests/baselines/reference/genericBaseClassLiteralProperty.js index 5e365531461..f8a5f78e753 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.js @@ -16,8 +16,7 @@ class SubClass extends BaseClass { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var BaseClass = (function () { function BaseClass() { diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.types b/tests/baselines/reference/genericBaseClassLiteralProperty.types index 51246348ded..87f1c55c42d 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.types @@ -14,7 +14,7 @@ class BaseClass { class SubClass extends BaseClass { >SubClass : SubClass ->BaseClass : BaseClass +>BaseClass : BaseClass public Error(): void { >Error : () => void diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.js b/tests/baselines/reference/genericBaseClassLiteralProperty2.js index 8a19d857bb6..d5c480955d8 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.js @@ -19,8 +19,7 @@ class DataView2 extends BaseCollection2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var CollectionItem2 = (function () { function CollectionItem2() { diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.types b/tests/baselines/reference/genericBaseClassLiteralProperty2.types index 4576ffb05de..271aa190037 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.types @@ -24,7 +24,7 @@ class BaseCollection2 { class DataView2 extends BaseCollection2 { >DataView2 : DataView2 ->BaseCollection2 : BaseCollection2 +>BaseCollection2 : BaseCollection2 >CollectionItem2 : CollectionItem2 fillItems(item: CollectionItem2) { diff --git a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js index f00468dcbc5..9df55756ee2 100644 --- a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js +++ b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js @@ -112,8 +112,7 @@ var r11 = i.foo8(); // Base var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js index 910e3860b49..bded01ead69 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js @@ -36,8 +36,7 @@ var r4 = f2(i); // Base => Derived var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js index 9cb2425f9d0..96c2f9300db 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js @@ -44,8 +44,7 @@ var r7 = f3(null, x => x); // any var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js index 3c5a4c24b53..daaa2f5c0eb 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js @@ -42,8 +42,7 @@ var r6 = f3(x => x, null); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js index 16abb2683e7..093757d513d 100644 --- a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js +++ b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js @@ -27,8 +27,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/genericCallbacksAndClassHierarchy.types b/tests/baselines/reference/genericCallbacksAndClassHierarchy.types index 97e584dca3f..cb12737a937 100644 --- a/tests/baselines/reference/genericCallbacksAndClassHierarchy.types +++ b/tests/baselines/reference/genericCallbacksAndClassHierarchy.types @@ -31,7 +31,7 @@ module M { export class B extends C1> { } >B : B >T : T ->C1 : C1 +>C1 : C1> >A : A >T : T diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js index 22bb975e7d7..f77f60a2fb9 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js @@ -9,8 +9,7 @@ class C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function (_super) { __extends(A, _super); diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types index 800b215f123..28daf6d38ee 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types @@ -1,7 +1,7 @@ === tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts === class A extends B { } >A : A ->B : B +>B : B class B extends C { } >B : B diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js index 43d1e53a615..69261747244 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js @@ -79,8 +79,7 @@ class ViewModel implements Contract { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Portal; (function (Portal) { diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types index 6ba27a66399..88ef74283ae 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types @@ -192,13 +192,13 @@ module PortalFx.ViewModels.Controls.Validators { export class Validator extends Portal.Controls.Validators.Validator { >Validator : Validator >TValue : TValue ->Portal.Controls.Validators.Validator : any +>Portal.Controls.Validators.Validator : Portal.Controls.Validators.Validator >Portal.Controls.Validators : typeof Portal.Controls.Validators >Portal.Controls : typeof Portal.Controls >Portal : typeof Portal >Controls : typeof Portal.Controls >Validators : typeof Portal.Controls.Validators ->Validator : Portal.Controls.Validators.Validator +>Validator : typeof Portal.Controls.Validators.Validator >TValue : TValue constructor(message?: string) { diff --git a/tests/baselines/reference/genericClassStaticMethod.js b/tests/baselines/reference/genericClassStaticMethod.js index 23e1874c0ed..aed721aa7d5 100644 --- a/tests/baselines/reference/genericClassStaticMethod.js +++ b/tests/baselines/reference/genericClassStaticMethod.js @@ -14,8 +14,7 @@ class Bar extends Foo { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/genericClasses3.js b/tests/baselines/reference/genericClasses3.js index 373052d78e3..14ffab2f6f6 100644 --- a/tests/baselines/reference/genericClasses3.js +++ b/tests/baselines/reference/genericClasses3.js @@ -21,8 +21,7 @@ var z = v2.b; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B() { diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js index 561c24cd50e..b4e56933775 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js @@ -30,8 +30,7 @@ module EndGate.Tweening { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var EndGate; (function (EndGate) { diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types index f1041cfa80f..9a4b209bc97 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types @@ -53,7 +53,7 @@ module EndGate.Tweening { export class NumberTween extends Tween{ >NumberTween : NumberTween ->Tween : Tween +>Tween : Tween constructor(from: number) { >from : number diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js index 2420e082e3d..54a807a8e87 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js @@ -29,8 +29,7 @@ module EndGate.Tweening { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var EndGate; (function (EndGate) { diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types index 92ffa7c5c03..ba42e42ae0c 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types @@ -52,7 +52,7 @@ module EndGate.Tweening { export class NumberTween extends Tween{ >NumberTween : NumberTween ->Tween : Tween +>Tween : Tween >Number : Number constructor(from: number) { diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js index 69ae509bf54..eb27365ebc5 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js @@ -16,8 +16,7 @@ x = y; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js index 1c4f27b5ebe..be94a778858 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js @@ -16,8 +16,7 @@ x = y; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/genericPrototypeProperty2.js b/tests/baselines/reference/genericPrototypeProperty2.js index b91b345481e..cbe33431ca4 100644 --- a/tests/baselines/reference/genericPrototypeProperty2.js +++ b/tests/baselines/reference/genericPrototypeProperty2.js @@ -19,8 +19,7 @@ class MyEventWrapper extends BaseEventWrapper { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var BaseEvent = (function () { function BaseEvent() { diff --git a/tests/baselines/reference/genericPrototypeProperty3.js b/tests/baselines/reference/genericPrototypeProperty3.js index de093886ea4..6447a4e0ac2 100644 --- a/tests/baselines/reference/genericPrototypeProperty3.js +++ b/tests/baselines/reference/genericPrototypeProperty3.js @@ -18,8 +18,7 @@ class MyEventWrapper extends BaseEventWrapper { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var BaseEvent = (function () { function BaseEvent() { diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js index b73239626d0..a1f7566f1c0 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js @@ -30,8 +30,7 @@ module TypeScript2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var TypeScript2; (function (TypeScript2) { diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js index 0d4a3315acd..a0229e19925 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js @@ -34,8 +34,7 @@ module TypeScript { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var TypeScript; (function (TypeScript) { diff --git a/tests/baselines/reference/genericTypeAssertions2.js b/tests/baselines/reference/genericTypeAssertions2.js index a3b88f599b9..22ff708592e 100644 --- a/tests/baselines/reference/genericTypeAssertions2.js +++ b/tests/baselines/reference/genericTypeAssertions2.js @@ -17,8 +17,7 @@ var r5: A = >[]; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/genericTypeAssertions4.js b/tests/baselines/reference/genericTypeAssertions4.js index 95ca5482b2e..d6d8672283c 100644 --- a/tests/baselines/reference/genericTypeAssertions4.js +++ b/tests/baselines/reference/genericTypeAssertions4.js @@ -29,8 +29,7 @@ function foo2(x: T) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/genericTypeAssertions6.js b/tests/baselines/reference/genericTypeAssertions6.js index d19da506680..30a5d5ff5e5 100644 --- a/tests/baselines/reference/genericTypeAssertions6.js +++ b/tests/baselines/reference/genericTypeAssertions6.js @@ -28,8 +28,7 @@ var c: A = >b; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(x) { diff --git a/tests/baselines/reference/genericTypeConstraints.errors.txt b/tests/baselines/reference/genericTypeConstraints.errors.txt index 9fd8b5f15be..ae97572b56a 100644 --- a/tests/baselines/reference/genericTypeConstraints.errors.txt +++ b/tests/baselines/reference/genericTypeConstraints.errors.txt @@ -1,9 +1,8 @@ -tests/cases/compiler/genericTypeConstraints.ts(9,27): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. - Property 'fooMethod' is missing in type 'FooExtended'. tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. + Property 'fooMethod' is missing in type 'FooExtended'. -==== tests/cases/compiler/genericTypeConstraints.ts (2 errors) ==== +==== tests/cases/compiler/genericTypeConstraints.ts (1 errors) ==== class Foo { fooMethod() {} } @@ -13,11 +12,9 @@ tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExt class Bar { } class BarExtended extends Bar { - ~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. -!!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'. ~~~~~~~~~~~ !!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. +!!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'. constructor() { super(); } diff --git a/tests/baselines/reference/genericTypeConstraints.js b/tests/baselines/reference/genericTypeConstraints.js index 6f0f235ccb8..eb8bed1fb92 100644 --- a/tests/baselines/reference/genericTypeConstraints.js +++ b/tests/baselines/reference/genericTypeConstraints.js @@ -17,8 +17,7 @@ class BarExtended extends Bar { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt index 5ae71fa2a89..2f6db48bf2f 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,27): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(16,25): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(22,28): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(22,28): error TS2339: Property 'C' does not exist on type 'typeof M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(23,28): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(25,30): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(26,30): error TS2314: Generic type 'E' requires 1 type argument(s). @@ -58,7 +58,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc declare class D2 extends M.C { } ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2339: Property 'C' does not exist on type 'typeof M'. declare class D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js index 5ec0a25af3d..0cbf3581706 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js @@ -43,8 +43,7 @@ var k = null; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt index 2949ce52ce0..e590ad42a7d 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt @@ -13,9 +13,9 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,23): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,27): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,38): error TS2314: Generic type 'I' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2314: Generic type 'I' requires 1 type argument(s). +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2304: Cannot find name 'I'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(23,21): error TS2314: Generic type 'I' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,20): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,18): error TS2304: Cannot find name 'M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(30,24): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(31,24): error TS2305: Module 'M' has no exported member 'C'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(33,22): error TS2314: Generic type 'I' requires 1 type argument(s). @@ -76,7 +76,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc class D extends I { ~ -!!! error TS2314: Generic type 'I' requires 1 type argument(s). +!!! error TS2304: Cannot find name 'I'. } interface U extends I {} @@ -88,8 +88,8 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc } class D2 extends M.C { } - ~ -!!! error TS2305: Module 'M' has no exported member 'C'. + ~ +!!! error TS2304: Cannot find name 'M'. interface D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js index 2f36a74de76..355030caa1b 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js @@ -43,8 +43,7 @@ var k = null; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var c; var a; diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt index c0e41374527..95857c925be 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,27): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(16,25): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(22,28): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(22,28): error TS2339: Property 'C' does not exist on type 'typeof M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(23,28): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(25,30): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(26,30): error TS2314: Generic type 'E' requires 1 type argument(s). @@ -58,7 +58,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc declare class D2 extends M.C { } ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2339: Property 'C' does not exist on type 'typeof M'. declare class D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js index 8142cd86407..2457d4a534e 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js @@ -18,8 +18,7 @@ export class ListItem extends CollectionItem { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; define(["require", "exports"], function (require, exports) { var Collection = (function () { diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types index e1cdfa85f13..2005604c83c 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types @@ -12,7 +12,7 @@ export class Collection { export class List extends Collection{ >List : List ->Collection : Collection +>Collection : Collection >ListItem : ListItem Bar() {} diff --git a/tests/baselines/reference/generics1.errors.txt b/tests/baselines/reference/generics1.errors.txt index 81d250a2ef4..6279c0dcd63 100644 --- a/tests/baselines/reference/generics1.errors.txt +++ b/tests/baselines/reference/generics1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/generics1.ts(10,9): error TS2344: Type 'A' does not satisfy the constraint 'B'. +tests/cases/compiler/generics1.ts(10,14): error TS2344: Type 'A' does not satisfy the constraint 'B'. Property 'b' is missing in type 'A'. tests/cases/compiler/generics1.ts(13,9): error TS2314: Generic type 'G' requires 2 type argument(s). tests/cases/compiler/generics1.ts(14,9): error TS2314: Generic type 'G' requires 2 type argument(s). @@ -15,7 +15,7 @@ tests/cases/compiler/generics1.ts(14,9): error TS2314: Generic type 'G' re var v1: G; // Ok var v2: G<{ a: string }, C>; // Ok, equivalent to G var v3: G; // Error, A not valid argument for U - ~~~~~~~ + ~ !!! error TS2344: Type 'A' does not satisfy the constraint 'B'. !!! error TS2344: Property 'b' is missing in type 'A'. var v4: G, C>; // Ok diff --git a/tests/baselines/reference/generics2.errors.txt b/tests/baselines/reference/generics2.errors.txt index a0380eee753..d44bc7baad8 100644 --- a/tests/baselines/reference/generics2.errors.txt +++ b/tests/baselines/reference/generics2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/generics2.ts(17,9): error TS2344: Type 'A' does not satisfy the constraint 'B'. +tests/cases/compiler/generics2.ts(17,14): error TS2344: Type 'A' does not satisfy the constraint 'B'. Property 'b' is missing in type 'A'. tests/cases/compiler/generics2.ts(20,9): error TS2314: Generic type 'G' requires 2 type argument(s). tests/cases/compiler/generics2.ts(21,9): error TS2314: Generic type 'G' requires 2 type argument(s). @@ -22,7 +22,7 @@ tests/cases/compiler/generics2.ts(21,9): error TS2314: Generic type 'G' re var v2: G<{ a: string }, C>; // Ok, equivalent to G var v3: G; // Error, A not valid argument for U - ~~~~~~~ + ~ !!! error TS2344: Type 'A' does not satisfy the constraint 'B'. !!! error TS2344: Property 'b' is missing in type 'A'. var v4: G, C>; // Ok diff --git a/tests/baselines/reference/generics5.errors.txt b/tests/baselines/reference/generics5.errors.txt index 17aeea63df2..fd21a705436 100644 --- a/tests/baselines/reference/generics5.errors.txt +++ b/tests/baselines/reference/generics5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/generics5.ts(10,9): error TS2344: Type 'A' does not satisfy the constraint 'B'. +tests/cases/compiler/generics5.ts(10,14): error TS2344: Type 'A' does not satisfy the constraint 'B'. Property 'b' is missing in type 'A'. @@ -13,7 +13,7 @@ tests/cases/compiler/generics5.ts(10,9): error TS2344: Type 'A' does not satisfy } var v3: G; // Error, A not valid argument for U - ~~~~~~~ + ~ !!! error TS2344: Type 'A' does not satisfy the constraint 'B'. !!! error TS2344: Property 'b' is missing in type 'A'. diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.js b/tests/baselines/reference/heterogeneousArrayLiterals.js index 26d1b09a6fc..45ea6429979 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.js +++ b/tests/baselines/reference/heterogeneousArrayLiterals.js @@ -136,8 +136,7 @@ function foo4(t: T, u: U) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = [1, '']; // {}[] var b = [1, null]; // number[] diff --git a/tests/baselines/reference/ifDoWhileStatements.js b/tests/baselines/reference/ifDoWhileStatements.js index d389f705707..020d3f053d1 100644 --- a/tests/baselines/reference/ifDoWhileStatements.js +++ b/tests/baselines/reference/ifDoWhileStatements.js @@ -166,8 +166,7 @@ do { }while(fn) var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.js b/tests/baselines/reference/illegalSuperCallsInConstructor.js index 57a382fe625..c3a52473744 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.js +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.js @@ -24,8 +24,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/implementClausePrecedingExtends.js b/tests/baselines/reference/implementClausePrecedingExtends.js index 7501c231dc8..a929c2fb966 100644 --- a/tests/baselines/reference/implementClausePrecedingExtends.js +++ b/tests/baselines/reference/implementClausePrecedingExtends.js @@ -6,8 +6,7 @@ class D implements C extends C { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js index 3d80d344850..cfa5ccf4150 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js @@ -89,8 +89,7 @@ module M2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js index 1fa40bf7aa2..39f30424321 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js @@ -45,8 +45,7 @@ class Bar8 extends Foo implements I { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/importAsBaseClass.errors.txt b/tests/baselines/reference/importAsBaseClass.errors.txt index f09eb55561b..835fd143f70 100644 --- a/tests/baselines/reference/importAsBaseClass.errors.txt +++ b/tests/baselines/reference/importAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2304: Cannot find name 'Greeter'. +tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2507: Type 'typeof "tests/cases/compiler/importAsBaseClass_0"' is not a constructor function type. ==== tests/cases/compiler/importAsBaseClass_1.ts (1 errors) ==== import Greeter = require("importAsBaseClass_0"); class Hello extends Greeter { } ~~~~~~~ -!!! error TS2304: Cannot find name 'Greeter'. +!!! error TS2507: Type 'typeof "tests/cases/compiler/importAsBaseClass_0"' is not a constructor function type. ==== tests/cases/compiler/importAsBaseClass_0.ts (0 errors) ==== export class Greeter { diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index 24f7e0477d6..b79905911b1 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -22,9 +22,9 @@ exports.Greeter = Greeter; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; +var Greeter = require("importAsBaseClass_0"); var Hello = (function (_super) { __extends(Hello, _super); function Hello() { diff --git a/tests/baselines/reference/importShadowsGlobalName.js b/tests/baselines/reference/importShadowsGlobalName.js index 6db46eb41b1..fe37e938a5a 100644 --- a/tests/baselines/reference/importShadowsGlobalName.js +++ b/tests/baselines/reference/importShadowsGlobalName.js @@ -23,8 +23,7 @@ define(["require", "exports"], function (require, exports) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; define(["require", "exports", 'Foo'], function (require, exports, Error) { var Bar = (function (_super) { diff --git a/tests/baselines/reference/importUsedInExtendsList1.js b/tests/baselines/reference/importUsedInExtendsList1.js index 3e07ee084f3..e86b1a41456 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.js +++ b/tests/baselines/reference/importUsedInExtendsList1.js @@ -22,8 +22,7 @@ exports.Super = Super; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// var foo = require('importUsedInExtendsList1_require'); diff --git a/tests/baselines/reference/importUsedInExtendsList1.types b/tests/baselines/reference/importUsedInExtendsList1.types index 74737c4db96..3c1b69f5a83 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.types +++ b/tests/baselines/reference/importUsedInExtendsList1.types @@ -5,9 +5,9 @@ import foo = require('importUsedInExtendsList1_require'); class Sub extends foo.Super { } >Sub : Sub ->foo.Super : any +>foo.Super : foo.Super >foo : typeof foo ->Super : foo.Super +>Super : typeof foo.Super var s: Sub; >s : Sub diff --git a/tests/baselines/reference/indexerConstraints2.js b/tests/baselines/reference/indexerConstraints2.js index 7d3966688db..7e662bc66cc 100644 --- a/tests/baselines/reference/indexerConstraints2.js +++ b/tests/baselines/reference/indexerConstraints2.js @@ -32,8 +32,7 @@ class K extends J { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/indirectSelfReference.errors.txt b/tests/baselines/reference/indirectSelfReference.errors.txt index e7c5a00d421..3f7d3d47f12 100644 --- a/tests/baselines/reference/indirectSelfReference.errors.txt +++ b/tests/baselines/reference/indirectSelfReference.errors.txt @@ -1,8 +1,11 @@ -tests/cases/compiler/indirectSelfReference.ts(1,7): error TS2310: Type 'a' recursively references itself as a base type. +tests/cases/compiler/indirectSelfReference.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReference.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReference.ts (1 errors) ==== +==== tests/cases/compiler/indirectSelfReference.ts (2 errors) ==== class a extends b{ } ~ -!!! error TS2310: Type 'a' recursively references itself as a base type. - class b extends a{ } \ No newline at end of file +!!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + class b extends a{ } + ~ +!!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReference.js b/tests/baselines/reference/indirectSelfReference.js index 3652d2962d0..bd838ed8810 100644 --- a/tests/baselines/reference/indirectSelfReference.js +++ b/tests/baselines/reference/indirectSelfReference.js @@ -6,8 +6,7 @@ class b extends a{ } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function (_super) { __extends(a, _super); diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt index 765112f0e99..5a6aeed5de1 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt @@ -1,8 +1,11 @@ -tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,7): error TS2310: Type 'a' recursively references itself as a base type. +tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReferenceGeneric.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (1 errors) ==== +==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (2 errors) ==== class a extends b { } ~ -!!! error TS2310: Type 'a' recursively references itself as a base type. - class b extends a { } \ No newline at end of file +!!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + class b extends a { } + ~ +!!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.js b/tests/baselines/reference/indirectSelfReferenceGeneric.js index 079a37dc201..c9b4478ec13 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.js +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.js @@ -6,8 +6,7 @@ class b extends a { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function (_super) { __extends(a, _super); diff --git a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js index 71390b03c83..f057b649cb6 100644 --- a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js +++ b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js @@ -28,8 +28,7 @@ o(A); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Functionality = (function () { function Functionality() { diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt index a9b3cb4b686..c043e37575c 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2311: A class may only extend another class. +tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'. tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface. ==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ==== class C extends T { } ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'T'. interface I extends T { } ~ !!! error TS2312: An interface may only extend a class or another interface. \ No newline at end of file diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.js b/tests/baselines/reference/inheritFromGenericTypeParameter.js index ccf445a26bf..ec6be00785f 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.js +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.js @@ -6,8 +6,7 @@ interface I extends T { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js index 850741c3666..93494c7256e 100644 --- a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js +++ b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js @@ -14,8 +14,7 @@ interface A extends C, C2 { // ok var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B() { diff --git a/tests/baselines/reference/inheritance.js b/tests/baselines/reference/inheritance.js index f2b5be9335e..b581ae894ae 100644 --- a/tests/baselines/reference/inheritance.js +++ b/tests/baselines/reference/inheritance.js @@ -38,8 +38,7 @@ class Baad extends Good { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B1 = (function () { function B1() { diff --git a/tests/baselines/reference/inheritance1.js b/tests/baselines/reference/inheritance1.js index e0d4fa974c5..aa7775b9904 100644 --- a/tests/baselines/reference/inheritance1.js +++ b/tests/baselines/reference/inheritance1.js @@ -65,8 +65,7 @@ l1 = c; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Control = (function () { function Control() { diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js index 0f016233ef3..927ae969049 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js @@ -14,8 +14,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js index 596982a4794..05d8dc2a541 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js @@ -14,8 +14,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js index ec8ae03b3e3..ddd87251f9f 100644 --- a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js @@ -14,8 +14,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js index 2da2bcbe6fe..eaf34df921b 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js @@ -21,8 +21,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js index 8b58a7f2b35..cd79d8c6964 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js @@ -18,8 +18,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js index 1864e62b237..18c1ab33952 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js @@ -16,8 +16,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js index 0b24db92a35..5c254251718 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js @@ -18,8 +18,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js index bf1186a5cde..e2d3d9551c2 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js @@ -15,8 +15,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js index 2ecf7edb0e8..b1d64aeb2c8 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js @@ -13,8 +13,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js index 512ca023dee..bfa5d3fb801 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js @@ -17,8 +17,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js index 975727031e3..d84f4879632 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js @@ -13,8 +13,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js index b924932e0b4..8677d502273 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js @@ -11,8 +11,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js index d62c62410b7..73d3b4aa6cb 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js @@ -11,8 +11,7 @@ var b3 = new B(); // error, could not select overload for 'new' expression var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js index c54f8b4d317..e7e6228392c 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js @@ -18,8 +18,7 @@ var n3 = new N.D2(); // no error, D2 var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types index 119b6a19046..c976e905db7 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types @@ -14,16 +14,16 @@ module N { export class D1 extends M.C1 { } >D1 : D1 ->M.C1 : any +>M.C1 : M.C1 >M : typeof M ->C1 : M.C1 +>C1 : typeof M.C1 export class D2 extends M.C2 { } >D2 : D2 >T : T ->M.C2 : any +>M.C2 : M.C2 >M : typeof M ->C2 : M.C2 +>C2 : typeof M.C2 >T : T } diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js index 120efc11e27..32f1d20eda1 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js @@ -21,8 +21,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js index 7200f37f94b..7a1a86ced18 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js @@ -18,8 +18,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js index 2fd5e18dab9..8a142d41c57 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js @@ -16,8 +16,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js index 812ac57bfe4..7c08ec7649e 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js @@ -18,8 +18,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js index 224c0326a87..acde620c100 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js @@ -15,8 +15,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js index 375f07fd905..abd4d7c1498 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js @@ -15,8 +15,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js index c4d3f7ca420..c2d095e5527 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js @@ -13,8 +13,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js index f9513f68585..979f0c36359 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js @@ -13,8 +13,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js index f64615e8a7c..5c6c0e06a6f 100644 --- a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js +++ b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js @@ -13,8 +13,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticMembersCompatible.js b/tests/baselines/reference/inheritanceStaticMembersCompatible.js index f1e288c57f5..014d3276189 100644 --- a/tests/baselines/reference/inheritanceStaticMembersCompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersCompatible.js @@ -11,8 +11,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js index 66ad8612538..a1728dc6dcb 100644 --- a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js @@ -11,8 +11,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js index 310f2127e7e..b81b6cd1d78 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js @@ -15,8 +15,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js index 3e8a444d772..9afa969af65 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js @@ -13,8 +13,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js index 088cfa9b1f9..fcecca62774 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js @@ -11,8 +11,7 @@ class b extends a { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = (function () { function a() { diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams.js b/tests/baselines/reference/inheritedConstructorWithRestParams.js index 45f4fe72535..a0bb2ed8dc1 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams.js @@ -18,8 +18,7 @@ new Derived(3); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams2.js b/tests/baselines/reference/inheritedConstructorWithRestParams2.js index eeb0413d1ec..9b87465233c 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams2.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams2.js @@ -38,8 +38,7 @@ new Derived("", 3, "", ""); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var IBaseBase = (function () { function IBaseBase(x) { diff --git a/tests/baselines/reference/inheritedModuleMembersForClodule.js b/tests/baselines/reference/inheritedModuleMembersForClodule.js index 75a2f13fed7..50f41af2c09 100644 --- a/tests/baselines/reference/inheritedModuleMembersForClodule.js +++ b/tests/baselines/reference/inheritedModuleMembersForClodule.js @@ -25,8 +25,7 @@ class E extends D { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js index 9e8e6d26b31..548cb77b878 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js @@ -46,8 +46,7 @@ module Generic { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var NonGeneric; (function (NonGeneric) { diff --git a/tests/baselines/reference/instanceSubtypeCheck2.js b/tests/baselines/reference/instanceSubtypeCheck2.js index e02a2b2afad..59043b29b4e 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.js +++ b/tests/baselines/reference/instanceSubtypeCheck2.js @@ -11,8 +11,7 @@ class C2 extends C1 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/instantiatedReturnTypeContravariance.js b/tests/baselines/reference/instantiatedReturnTypeContravariance.js index 678f324797f..2484816fe33 100644 --- a/tests/baselines/reference/instantiatedReturnTypeContravariance.js +++ b/tests/baselines/reference/instantiatedReturnTypeContravariance.js @@ -34,8 +34,7 @@ return null; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var c = (function () { function c() { diff --git a/tests/baselines/reference/interfaceExtendsClass1.js b/tests/baselines/reference/interfaceExtendsClass1.js index 5e72b36ef30..2fbe01bdf67 100644 --- a/tests/baselines/reference/interfaceExtendsClass1.js +++ b/tests/baselines/reference/interfaceExtendsClass1.js @@ -22,8 +22,7 @@ class Location { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Control = (function () { function Control() { diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js index dac502b9ca3..9a6e92c3e2b 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js @@ -31,8 +31,7 @@ d = c; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js index c6a11c1d3ab..44738036f96 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js @@ -27,8 +27,7 @@ class D2 extends C implements I { // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/interfaceImplementation8.js b/tests/baselines/reference/interfaceImplementation8.js index 64b4c453829..cb6eaa12450 100644 --- a/tests/baselines/reference/interfaceImplementation8.js +++ b/tests/baselines/reference/interfaceImplementation8.js @@ -44,8 +44,7 @@ class C8 extends C7 implements i2{ var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js index 4b3ab1b6d88..0b662b56f06 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js @@ -83,8 +83,7 @@ module YYY4 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Y; (function (Y) { diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.js b/tests/baselines/reference/invalidMultipleVariableDeclarations.js index 31d0e44c918..b239a3dc1dd 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.js +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.js @@ -57,8 +57,7 @@ var m = M.A; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/invalidReturnStatements.js b/tests/baselines/reference/invalidReturnStatements.js index 50977334f4c..5fbe8c4dc37 100644 --- a/tests/baselines/reference/invalidReturnStatements.js +++ b/tests/baselines/reference/invalidReturnStatements.js @@ -24,8 +24,7 @@ function fn11(): D { return new C(); } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // all the following should be error function fn1() { } diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index ca3eee0ac2b..8cb65747e6f 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -17,8 +17,7 @@ export var z = x; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var module_1 = require("module"); var module_2 = require("module"); diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 3701cc85ed8..6f0d347d9b4 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1899, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt new file mode 100644 index 00000000000..aebabf15133 --- /dev/null +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,13): error TS2304: Cannot find name 'test'. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,17): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,32): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,36): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,45): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS1005: ':' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'any'. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'foo'. + + +==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (8 errors) ==== + + declare var createElement: any; + + class foo {} + + var x: any; + x = { test: }; + ~~~~ +!!! error TS2304: Cannot find name 'test'. + ~ +!!! error TS1005: '}' expected. + + x = ; + + x = hello {{}} ; + ~ +!!! error TS1005: '}' expected. + + x = {}}>hello; + ~ +!!! error TS1005: '}' expected. + + x = {}}>hello{{}}; + ~ +!!! error TS1005: '}' expected. + + x = x, x = ; + + {{/foo/.test(x) ? : }} + + + + +!!! error TS1005: ':' expected. + +!!! error TS17002: Expected corresponding JSX closing tag for 'any'. + +!!! error TS17002: Expected corresponding JSX closing tag for 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxAndTypeAssertion.js b/tests/baselines/reference/jsxAndTypeAssertion.js new file mode 100644 index 00000000000..0b402b43de2 --- /dev/null +++ b/tests/baselines/reference/jsxAndTypeAssertion.js @@ -0,0 +1,49 @@ +//// [jsxAndTypeAssertion.tsx] + +declare var createElement: any; + +class foo {} + +var x: any; +x = { test: }; + +x = ; + +x = hello {{}} ; + +x = {}}>hello; + +x = {}}>hello{{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + + + + +//// [jsxAndTypeAssertion.jsx] +var foo = (function () { + function foo() { + } + return foo; +})(); +var x; +x = {test}: }; + +x = ; + +x = hello {} }; + +x = }>hello}/>; + +x = }>hello{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + : +} + + +}}/>; diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt new file mode 100644 index 00000000000..5758db36960 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,17): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,23): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,29): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,57): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,58): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,12): error TS1109: Expression expected. + + +==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (8 errors) ==== + declare var React: any; + declare var 日本語; + declare var AbC_def; + declare var LeftRight; + declare var x; + declare var a; + declare var props; + + ; + + //; Namespace unsuported + + // {value} ; Namespace unsuported + + ; + + ; + ; + + <日本語>; + + + bar + baz + ; + + : } />; + + {}; + + {/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + ~ +!!! error TS1005: '{' expected. + ~~~~~ +!!! error TS1005: '}' expected. + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + + ; + ~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + + ; + + (
) < x; + +
; + +
; + +
; + + ; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.js b/tests/baselines/reference/jsxEsprimaFbTestSuite.js new file mode 100644 index 00000000000..1e22826f440 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.js @@ -0,0 +1,82 @@ +//// [jsxEsprimaFbTestSuite.tsx] +declare var React: any; +declare var 日本語; +declare var AbC_def; +declare var LeftRight; +declare var x; +declare var a; +declare var props; + +; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; + +; +; + +<日本語>; + + +bar +baz +; + + : } />; + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + +; + +; + +(
) < x; + +
; + +
; + +
; + + ; + + +//// [jsxEsprimaFbTestSuite.jsx] +; +//; Namespace unsuported +// {value} ; Namespace unsuported +; +; +; +<日本語>; + +bar +baz +; + : }/>; +; +; +
@test content
; +

7x invalid-js-identifier
; +} right={monkeys /> gorillas / > }/> + < a.b > ; +a.b > ; +; +(
) < x; +
; +
; +
; + ; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt new file mode 100644 index 00000000000..3e2a10e9931 --- /dev/null +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -0,0 +1,251 @@ +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,4): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,3): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,7): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS2304: Cannot find name 'd'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,4): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,4): error TS17002: Expected corresponding JSX closing tag for 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,13): error TS1002: Unterminated string literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,3): error TS1005: ';' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,8): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,12): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,14): error TS2304: Cannot find name 'c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,5): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,13): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,11): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,22): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,10): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,20): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,15): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS1005: '...' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,17): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,29): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002: Expected corresponding JSX closing tag for 'a'. + + +==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (71 errors) ==== + declare var React: any; + + ; + ~~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1003: Identifier expected. + <:a />; + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS2304: Cannot find name 'd'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. + ; + ~~~~ +!!! error TS17002: Expected corresponding JSX closing tag for 'a'. + ; + ~ +!!! error TS1005: '}' expected. + ; + ~ +!!! error TS1003: Identifier expected. +
; + ~~~~~ +!!! error TS1003: Identifier expected. +
; + ~~~~~ +!!! error TS1005: '...' expected. + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + +
stuff
; + ~ +!!! error TS1005: '>' expected. + ~~~ +!!! error TS1109: Expression expected. +
stuff
; + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + ~ +!!! error TS1005: '>' expected. + ~~~ +!!! error TS1109: Expression expected. + +
>; + >; + ; + ~ +!!! error TS1005: '{' expected. + ; + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS1109: Expression expected. + }; + ; + ~~~ +!!! error TS1003: Identifier expected. + +!!! error TS17002: Expected corresponding JSX closing tag for 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js new file mode 100644 index 00000000000..13808cc29e0 --- /dev/null +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -0,0 +1,81 @@ +//// [jsxInvalidEsprimaTestSuite.tsx] +declare var React: any; + +; +; +<:a />; +; +; +
; +; +; +
; +
; + +
stuff
; +
stuff
; + +
>; + >; +; +; +}; +; + +//// [jsxInvalidEsprimaTestSuite.jsx] + > ; +; + < ; +a / > ; + }/> + < a > ; +; +; +, id="b" />; +
"app">; +
; + +
stuff
{}...props}>; +
stuff
{}...props}>; + +
>; + >; +; +; +}; + .../*hai*/asdf/>;; diff --git a/tests/baselines/reference/jsxReactTestSuite.js b/tests/baselines/reference/jsxReactTestSuite.js new file mode 100644 index 00000000000..300274a1614 --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.js @@ -0,0 +1,171 @@ +//// [jsxReactTestSuite.tsx] + +declare var React: any; +declare var Component:any; +declare var Composite:any; +declare var Composite2:any; +declare var Child:any; +declare var Namespace:any; +declare var foo: any; +declare var bar: any; +declare var y:any; +declare var x:any; +declare var z:any; +declare var hasOwnProperty:any; + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+
+
; + + + + {this.props.children} +; + + + +; + +var x = +
+
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+ +
+); + +
 
; + +
 
; + +testing; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + + +; + +Text; + + + + +//// [jsxReactTestSuite.jsx] +
text
; +
+ {this.props.children} +
; +
+

+ {foo}
{bar}
+
+
; + + {this.props.children} +; + + +; +var x =
+
; +(
+ + + + + + +
+ + +
); +(
+ +
); +
 
; +
 
; +testing; +; +; +; +; +; +; +; +; +; +; +; +; +; +Text; diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols new file mode 100644 index 00000000000..9e382742f0d --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/jsxReactTestSuite.tsx === + +declare var React: any; +>React : Symbol(React, Decl(jsxReactTestSuite.tsx, 1, 11)) + +declare var Component:any; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +declare var Composite:any; +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + +declare var Composite2:any; +>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) + +declare var Child:any; +>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) + +declare var Namespace:any; +>Namespace : Symbol(Namespace, Decl(jsxReactTestSuite.tsx, 6, 11)) + +declare var foo: any; +>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11)) + +declare var bar: any; +>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11)) + +declare var y:any; +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) + +declare var x:any; +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) + +declare var z:any; +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) + +declare var hasOwnProperty:any; +>hasOwnProperty : Symbol(hasOwnProperty, Decl(jsxReactTestSuite.tsx, 12, 11)) + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +
+
; + + + +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + + {this.props.children} +; + + +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + + +>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) + +; + +var x = +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) + +
attr1 : Symbol(unknown) + + "foo" + "bar" + } + attr2={ +>attr2 : Symbol(unknown) + + "foo" + "bar" + + + "baz" + "bug" + } + attr3={ +>attr3 : Symbol(unknown) + + "foo" + "bar" + + "baz" + "bug" + // Extra line here. + } + attr4="baz"> +>attr4 : Symbol(unknown) + +
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+>attr1 : Symbol(unknown) + + attr2 : Symbol(unknown) + + /> +
+); + +
 
; + +
 
; + +testing; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>constructor : Symbol(unknown) + +; +>Component : Symbol(unknown) + +; +>Component : Symbol(unknown) + +Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) + +={2 } z />; +>z : Symbol(unknown) + +Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + + {...this.props} sound="moo" />; +>sound : Symbol(unknown) + +; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) + +; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) +>z : Symbol(unknown) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) + + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) +>y : Symbol(unknown) +>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) + +Text; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 113, 27)) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>z : Symbol(unknown) + + + diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types new file mode 100644 index 00000000000..db7ebf8d912 --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -0,0 +1,332 @@ +=== tests/cases/conformance/jsx/jsxReactTestSuite.tsx === + +declare var React: any; +>React : any + +declare var Component:any; +>Component : any + +declare var Composite:any; +>Composite : any + +declare var Composite2:any; +>Composite2 : any + +declare var Child:any; +>Child : any + +declare var Namespace:any; +>Namespace : any + +declare var foo: any; +>foo : any + +declare var bar: any; +>bar : any + +declare var y:any; +>y : any + +declare var x:any; +>x : any + +declare var z:any; +>z : any + +declare var hasOwnProperty:any; +>hasOwnProperty : any + +
text
; +>
text
: any +>div : any +>div : any + +
+>
{this.props.children}
: any +>div : any + + {this.props.children} +>this.props.children : any +>this.props : any +>this : any +>props : any +>children : any + +
; +>div : any + +
+>

{foo}
{bar}

: any +>div : any + +

+>

: any +>div : any +>
: any +>br : any +>div : any + + {foo}
{bar}
+>{foo}
{bar}
: any +>Component : any +>foo : any +>
: any +>br : any +>bar : any +>Component : any + +
+>
: any +>br : any + +
; +>div : any + + + +> {this.props.children} : any +>Composite : any + + {this.props.children} +>this.props.children : any +>this.props : any +>this : any +>props : any +>children : any + +; +>Composite : any + + +> : any +>Composite : any + + +> : any +>Composite2 : any + +; +>Composite : any + +var x = +>x : any + +
: any +>div : any + + attr1={ +>attr1 : any + + "foo" + "bar" +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + } + attr2={ +>attr2 : any + + "foo" + "bar" + +>"foo" + "bar" + "baz" + "bug" : string +>"foo" + "bar" + "baz" : string +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + + "baz" + "bug" +>"baz" : string +>"bug" : string + } + attr3={ +>attr3 : any + + "foo" + "bar" + +>"foo" + "bar" + "baz" + "bug" : string +>"foo" + "bar" + "baz" : string +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + + "baz" + "bug" +>"baz" : string +>"bug" : string + + // Extra line here. + } + attr4="baz"> +>attr4 : any + +
; +>div : any + +( +>(
{/* A comment at the beginning */} {/* A second comment at the beginning */} {/* A nested comment */} {/* A sandwiched comment */}
{/* A comment at the end */} {/* A second comment at the end */}
) : any + +
+>
{/* A comment at the beginning */} {/* A second comment at the beginning */} {/* A nested comment */} {/* A sandwiched comment */}
{/* A comment at the end */} {/* A second comment at the end */}
: any +>div : any + + {/* A comment at the beginning */} + {/* A second comment at the beginning */} + +> {/* A nested comment */} : any +>span : any + + {/* A nested comment */} + +>span : any + + {/* A sandwiched comment */} +
+>
: any +>br : any + + {/* A comment at the end */} + {/* A second comment at the end */} +
+>div : any + +); + +( +>(
) : any + +
: any +>div : any + + /* a multi-line + comment */ + attr1="foo"> +>attr1 : any + + : any +>span : any + + attr2="bar" +>attr2 : any + + /> +
+>div : any + +); + +
 
; +>
 
: any +>div : any +>div : any + +
 
; +>
 
: any +>div : any +>div : any + +testing; +>testing : any +>hasOwnProperty : any +>hasOwnProperty : any + +; +> : any +>Component : any +>constructor : any + +; +> : any +>Namespace : any +>Component : any + +; +> : any +>Namespace : any +>DeepNamespace : any +>Component : any + + : any +>Component : any +>x : any +>y : any + +={2 } z />; +>z : any + + : any +>Component : any + + {...this.props} sound="moo" />; +>this.props : any +>this : any +>props : any +>sound : any + +; +> : any +>font-face : any + +; +> : any +>Component : any +>x : any +>y : any + +; +> : any +>x-component : any + +; +> : any +>Component : any +>x : any + +; +> : any +>Component : any +>x : any +>y : any + +; +> : any +>Component : any +>x : any +>y : any +>z : any + +; +> : any +>Component : any +>x : any +>y : any + + +; +> : any +>Component : any +>x : any +>y : any +>z : any +>z : any +> : any +>Child : any +>Component : any + +Text; +>Text : any +>Component : any +>x : any +>(z = { y: 2 }, z) : any +>z = { y: 2 }, z : any +>z = { y: 2 } : { y: number; } +>z : any +>{ y: 2 } : { y: number; } +>y : number +>2 : number +>z : any +>z : any +>Component : any + + + diff --git a/tests/baselines/reference/lambdaArgCrash.js b/tests/baselines/reference/lambdaArgCrash.js index 0f71ae803d6..5616b5d525f 100644 --- a/tests/baselines/reference/lambdaArgCrash.js +++ b/tests/baselines/reference/lambdaArgCrash.js @@ -38,8 +38,7 @@ class ItemSetEvent extends Event { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Event = (function () { function Event() { diff --git a/tests/baselines/reference/lift.js b/tests/baselines/reference/lift.js index eaaf94e7024..a832b34641d 100644 --- a/tests/baselines/reference/lift.js +++ b/tests/baselines/reference/lift.js @@ -21,8 +21,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B(y) { diff --git a/tests/baselines/reference/localTypes1.js b/tests/baselines/reference/localTypes1.js index 09fa9c04f3c..00c65db2c96 100644 --- a/tests/baselines/reference/localTypes1.js +++ b/tests/baselines/reference/localTypes1.js @@ -145,8 +145,7 @@ function f6() { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function f1() { var E; diff --git a/tests/baselines/reference/m7Bugs.js b/tests/baselines/reference/m7Bugs.js index 72829316fb8..86b5aa96c77 100644 --- a/tests/baselines/reference/m7Bugs.js +++ b/tests/baselines/reference/m7Bugs.js @@ -30,8 +30,7 @@ var y3: C1 = {}; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var s = ({}); var x = {}; diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js index 389bbfa63dd..26cd3c8bf7c 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js @@ -35,8 +35,7 @@ var r2 = a.w; // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js index d088aab3d3c..530595d54f6 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js @@ -42,8 +42,7 @@ module M { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/missingDecoratorType.errors.txt b/tests/baselines/reference/missingDecoratorType.errors.txt index 0b159a8fcb2..f2af7d49b57 100644 --- a/tests/baselines/reference/missingDecoratorType.errors.txt +++ b/tests/baselines/reference/missingDecoratorType.errors.txt @@ -1,7 +1,7 @@ -error TS2318: Cannot find global type 'ClassDecorator'. +error TS2318: Cannot find global type 'TypedPropertyDescriptor'. -!!! error TS2318: Cannot find global type 'ClassDecorator'. +!!! error TS2318: Cannot find global type 'TypedPropertyDescriptor'. ==== tests/cases/conformance/decorators/a.ts (0 errors) ==== interface Object { } @@ -14,10 +14,11 @@ error TS2318: Cannot find global type 'ClassDecorator'. interface IArguments { } ==== tests/cases/conformance/decorators/b.ts (0 errors) ==== - declare var dec: any; + declare function dec(t, k, d); - @dec class C { + @dec + method() {} } \ No newline at end of file diff --git a/tests/baselines/reference/missingDecoratorType.js b/tests/baselines/reference/missingDecoratorType.js index 4460abdc798..ad6be3a646e 100644 --- a/tests/baselines/reference/missingDecoratorType.js +++ b/tests/baselines/reference/missingDecoratorType.js @@ -12,10 +12,11 @@ interface RegExp { } interface IArguments { } //// [b.ts] -declare var dec: any; +declare function dec(t, k, d); -@dec class C { + @dec + method() {} } @@ -33,8 +34,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec - ], C); + C.prototype.method = function () { }; + Object.defineProperty(C.prototype, "method", + __decorate([ + dec + ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); return C; })(); diff --git a/tests/baselines/reference/moduleAsBaseType.js b/tests/baselines/reference/moduleAsBaseType.js index c2246be8795..7e2af06480d 100644 --- a/tests/baselines/reference/moduleAsBaseType.js +++ b/tests/baselines/reference/moduleAsBaseType.js @@ -8,8 +8,7 @@ class C2 implements M { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js index e8e08eed26c..9b7449b95ca 100644 --- a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js +++ b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js @@ -18,8 +18,7 @@ define(["require", "exports"], function (require, exports) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; define(["require", "exports"], function (require, exports) { var C1 = (function () { diff --git a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types index 0a85e6e0002..d3ef4e4e9ce 100644 --- a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types +++ b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types @@ -9,7 +9,7 @@ class C1{ } class Test1 extends C1 { >Test1 : Test1 ->C1 : C1 +>C1 : C1 >M2 : any >M2C : M2.M2C } diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js index 6c0f625f986..aeffc8d6e5b 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js @@ -62,8 +62,7 @@ module Y { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A; (function (A_1) { diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.types b/tests/baselines/reference/moduleWithStatementsOfEveryKind.types index 9475d9cfdcb..c6f4be850be 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.types +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.types @@ -18,7 +18,7 @@ module A { class B extends AA implements I { id: number } >B : B ->AA : AA +>AA : AA >I : I >id : number @@ -106,7 +106,7 @@ module Y { export class B extends AA implements I { id: number } >B : B ->AA : AA +>AA : AA >I : I >id : number diff --git a/tests/baselines/reference/multipleInheritance.js b/tests/baselines/reference/multipleInheritance.js index ea4a7156df9..901838b584b 100644 --- a/tests/baselines/reference/multipleInheritance.js +++ b/tests/baselines/reference/multipleInheritance.js @@ -42,8 +42,7 @@ class Baad extends Good { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B1 = (function () { function B1() { diff --git a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js index 9b3d6f31291..09f4be0c4e9 100644 --- a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js +++ b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js @@ -14,8 +14,7 @@ var test = new foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var foo = (function () { function foo() { diff --git a/tests/baselines/reference/namespacesDeclaration.js b/tests/baselines/reference/namespacesDeclaration.js new file mode 100644 index 00000000000..7c7cfa84af0 --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration.js @@ -0,0 +1,22 @@ +//// [namespacesDeclaration.ts] + +module M { + export namespace N { + export module M2 { + export interface I {} + } + } +} + +//// [namespacesDeclaration.js] + + +//// [namespacesDeclaration.d.ts] +declare module M { + namespace N { + module M2 { + interface I { + } + } + } +} diff --git a/tests/baselines/reference/namespacesDeclaration.symbols b/tests/baselines/reference/namespacesDeclaration.symbols new file mode 100644 index 00000000000..1706f212f34 --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/namespacesDeclaration.ts === + +module M { +>M : Symbol(M, Decl(namespacesDeclaration.ts, 0, 0)) + + export namespace N { +>N : Symbol(N, Decl(namespacesDeclaration.ts, 1, 10)) + + export module M2 { +>M2 : Symbol(M2, Decl(namespacesDeclaration.ts, 2, 23)) + + export interface I {} +>I : Symbol(I, Decl(namespacesDeclaration.ts, 3, 24)) + } + } +} diff --git a/tests/baselines/reference/namespacesDeclaration.types b/tests/baselines/reference/namespacesDeclaration.types new file mode 100644 index 00000000000..944098097fc --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/namespacesDeclaration.ts === + +module M { +>M : any + + export namespace N { +>N : any + + export module M2 { +>M2 : any + + export interface I {} +>I : I + } + } +} diff --git a/tests/baselines/reference/noEmitHelpers2.js b/tests/baselines/reference/noEmitHelpers2.js index 1bd42377679..66e2ff78b64 100644 --- a/tests/baselines/reference/noEmitHelpers2.js +++ b/tests/baselines/reference/noEmitHelpers2.js @@ -1,6 +1,6 @@ //// [noEmitHelpers2.ts] -function decorator() { } +declare var decorator: any; @decorator class A { @@ -9,7 +9,6 @@ class A { } //// [noEmitHelpers2.js] -function decorator() { } var A = (function () { function A(a, b) { } diff --git a/tests/baselines/reference/noEmitHelpers2.symbols b/tests/baselines/reference/noEmitHelpers2.symbols index 3a3e3ec94c7..044026a3db7 100644 --- a/tests/baselines/reference/noEmitHelpers2.symbols +++ b/tests/baselines/reference/noEmitHelpers2.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/noEmitHelpers2.ts === -function decorator() { } ->decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0)) +declare var decorator: any; +>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 1, 11)) @decorator ->decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0)) +>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 1, 11)) class A { ->A : Symbol(A, Decl(noEmitHelpers2.ts, 1, 24)) +>A : Symbol(A, Decl(noEmitHelpers2.ts, 1, 27)) constructor(a: number, @decorator b: string) { >a : Symbol(a, Decl(noEmitHelpers2.ts, 5, 16)) ->decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0)) +>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 1, 11)) >b : Symbol(b, Decl(noEmitHelpers2.ts, 5, 26)) } } diff --git a/tests/baselines/reference/noEmitHelpers2.types b/tests/baselines/reference/noEmitHelpers2.types index 2a5b5413a7e..14260e4f95c 100644 --- a/tests/baselines/reference/noEmitHelpers2.types +++ b/tests/baselines/reference/noEmitHelpers2.types @@ -1,17 +1,17 @@ === tests/cases/compiler/noEmitHelpers2.ts === -function decorator() { } ->decorator : () => void +declare var decorator: any; +>decorator : any @decorator ->decorator : () => void +>decorator : any class A { >A : A constructor(a: number, @decorator b: string) { >a : number ->decorator : () => void +>decorator : any >b : string } } diff --git a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js index b687162c154..7cdb702d6ff 100644 --- a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js +++ b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js @@ -9,8 +9,7 @@ class Bar extends Foo { } // Valid var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types index 177becac643..4eb4c61aedf 100644 --- a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types +++ b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types @@ -10,5 +10,5 @@ class Foo { class Bar extends Foo { } // Valid >Bar : Bar ->Foo : Foo +>Foo : Foo diff --git a/tests/baselines/reference/numLit.errors.txt b/tests/baselines/reference/numLit.errors.txt deleted file mode 100644 index 98b84791e35..00000000000 --- a/tests/baselines/reference/numLit.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/compiler/numLit.ts(3,3): error TS1005: ';' expected. -tests/cases/compiler/numLit.ts(3,3): error TS2304: Cannot find name 'toString'. - - -==== tests/cases/compiler/numLit.ts (2 errors) ==== - 1..toString(); - 1.0.toString(); - 1.toString(); - ~~~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'toString'. - 1.+2.0 + 3. ; \ No newline at end of file diff --git a/tests/baselines/reference/numLit.js b/tests/baselines/reference/numLit.js deleted file mode 100644 index aaec91cde5d..00000000000 --- a/tests/baselines/reference/numLit.js +++ /dev/null @@ -1,12 +0,0 @@ -//// [numLit.ts] -1..toString(); -1.0.toString(); -1.toString(); -1.+2.0 + 3. ; - -//// [numLit.js] -1..toString(); -1.0.toString(); -1.; -toString(); -1. + 2.0 + 3.; diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js index fe1e4768672..ade000d50ba 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js @@ -50,8 +50,7 @@ var b: { [x: number]: A } = { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/numericIndexerConstraint3.js b/tests/baselines/reference/numericIndexerConstraint3.js index 724db29f557..dc3b6024eee 100644 --- a/tests/baselines/reference/numericIndexerConstraint3.js +++ b/tests/baselines/reference/numericIndexerConstraint3.js @@ -16,8 +16,7 @@ class C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/numericIndexerConstraint4.js b/tests/baselines/reference/numericIndexerConstraint4.js index 404a9394bf7..7509c64eac8 100644 --- a/tests/baselines/reference/numericIndexerConstraint4.js +++ b/tests/baselines/reference/numericIndexerConstraint4.js @@ -15,8 +15,7 @@ var x: { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/numericIndexerTyping2.js b/tests/baselines/reference/numericIndexerTyping2.js index c5e91e9dfc0..2e3ba2ce74c 100644 --- a/tests/baselines/reference/numericIndexerTyping2.js +++ b/tests/baselines/reference/numericIndexerTyping2.js @@ -16,8 +16,7 @@ var r2: string = i2[1]; // error: numeric indexer returns the type of the string var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var I = (function () { function I() { diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt new file mode 100644 index 00000000000..f08750ff0a6 --- /dev/null +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(3,3): error TS1005: ';' expected. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,15): error TS1005: ',' expected. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: '=' expected. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error TS1109: Expression expected. + + +==== tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts (4 errors) ==== + 1..toString(); + 1.0.toString(); + 1.toString(); + ~~~~~~~~ +!!! error TS1005: ';' expected. + 1.+2.0 + 3. ; + + // Preserve whitespace where important for JS compatibility + var i: number = 1; + var test1 = i.toString(); + var test2 = 2.toString(); + ~~~~~~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1109: Expression expected. + var test3 = 3 .toString(); + var test4 = 3 .toString(); + var test5 = 3 .toString(); + var test6 = 3.['toString'](); + var test7 = 3 + .toString(); + var test8 = new Number(4).toString(); + var test9 = 3. + 3. + \ No newline at end of file diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js new file mode 100644 index 00000000000..0b1ce1f0736 --- /dev/null +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js @@ -0,0 +1,38 @@ +//// [numericLiteralsWithTrailingDecimalPoints01.ts] +1..toString(); +1.0.toString(); +1.toString(); +1.+2.0 + 3. ; + +// Preserve whitespace where important for JS compatibility +var i: number = 1; +var test1 = i.toString(); +var test2 = 2.toString(); +var test3 = 3 .toString(); +var test4 = 3 .toString(); +var test5 = 3 .toString(); +var test6 = 3.['toString'](); +var test7 = 3 +.toString(); +var test8 = new Number(4).toString(); +var test9 = 3. + 3. + + +//// [numericLiteralsWithTrailingDecimalPoints01.js] +1..toString(); +1.0.toString(); +1.; +toString(); +1. + 2.0 + 3.; +// Preserve whitespace where important for JS compatibility +var i = 1; +var test1 = i.toString(); +var test2 = 2., toString = (); +var test3 = 3 .toString(); +var test4 = 3 .toString(); +var test5 = 3 .toString(); +var test6 = 3.['toString'](); +var test7 = 3 + .toString(); +var test8 = new Number(4).toString(); +var test9 = 3. + 3.; diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.js b/tests/baselines/reference/objectCreationOfElementAccessExpression.js index 45d56a1d716..05457a559e9 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.js +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.js @@ -59,8 +59,7 @@ var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Co var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Food = (function () { function Food(name) { diff --git a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js index 339f6b23f6a..5d30e0faecf 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js +++ b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js @@ -58,8 +58,7 @@ var r4: void = b.valueOf(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js index 8f6d1706e40..e0f626ae083 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js @@ -127,8 +127,7 @@ function foo16(x: any) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js index 8f5b6449a88..f0417a7ca23 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js @@ -130,8 +130,7 @@ function foo16(x: any) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js index 2fc8c0c946d..e1473790553 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js @@ -127,8 +127,7 @@ function foo16(x: any) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates.js b/tests/baselines/reference/objectTypesIdentityWithPrivates.js index a68eba8c6a2..bf4f80da15a 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates.js @@ -125,8 +125,7 @@ function foo16(x: any) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js index 92aac37ecdb..c8cd12cff30 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js @@ -43,8 +43,7 @@ function foo6(x: any): any { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js index c202f684895..a812a1fc4bd 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js @@ -29,8 +29,7 @@ var c3: C3; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js index 98693b4e6ee..9cf9e99cb4b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js @@ -127,8 +127,7 @@ function foo16(x: any) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js index 7e9abbad7e6..84f3d04e7bf 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js @@ -130,8 +130,7 @@ function foo16(x: any) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/optionalConstructorArgInSuper.js b/tests/baselines/reference/optionalConstructorArgInSuper.js index 2ac23c39be5..e8b65ea5119 100644 --- a/tests/baselines/reference/optionalConstructorArgInSuper.js +++ b/tests/baselines/reference/optionalConstructorArgInSuper.js @@ -14,8 +14,7 @@ d2.foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(opt) { diff --git a/tests/baselines/reference/optionalParamArgsTest.js b/tests/baselines/reference/optionalParamArgsTest.js index 7538397566a..414f474598d 100644 --- a/tests/baselines/reference/optionalParamArgsTest.js +++ b/tests/baselines/reference/optionalParamArgsTest.js @@ -129,8 +129,7 @@ fnOpt2(1, [2, 3], [1], true); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // test basic configurations var C1 = (function () { diff --git a/tests/baselines/reference/optionalParamInOverride.js b/tests/baselines/reference/optionalParamInOverride.js index aa76f41644c..4a72953bdad 100644 --- a/tests/baselines/reference/optionalParamInOverride.js +++ b/tests/baselines/reference/optionalParamInOverride.js @@ -11,8 +11,7 @@ class Y extends Z { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Z = (function () { function Z() { diff --git a/tests/baselines/reference/overload1.js b/tests/baselines/reference/overload1.js index b308c0e8d83..af3aebde4ee 100644 --- a/tests/baselines/reference/overload1.js +++ b/tests/baselines/reference/overload1.js @@ -43,8 +43,7 @@ var v=x.g; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var O; (function (O) { diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks1.js b/tests/baselines/reference/overloadOnConstConstraintChecks1.js index 4588bef017b..67aa365ee39 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks1.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks1.js @@ -26,8 +26,7 @@ class D implements MyDoc { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks2.js b/tests/baselines/reference/overloadOnConstConstraintChecks2.js index 709f7808ac1..353680bb92e 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks2.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks2.js @@ -15,8 +15,7 @@ function foo(name: any): A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks3.js b/tests/baselines/reference/overloadOnConstConstraintChecks3.js index 7104c441938..2debaa589f5 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks3.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks3.js @@ -16,8 +16,7 @@ function foo(name: any): A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks4.js b/tests/baselines/reference/overloadOnConstConstraintChecks4.js index 4483b42a941..17ec3779620 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks4.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks4.js @@ -17,8 +17,7 @@ function foo(name: any): Z { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Z = (function () { function Z() { diff --git a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js index efcad011ab5..a8dfcde9ada 100644 --- a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js +++ b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js @@ -15,8 +15,7 @@ foo("HI"); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/overloadResolution.js b/tests/baselines/reference/overloadResolution.js index d234ea4a69a..287c5ccdb8e 100644 --- a/tests/baselines/reference/overloadResolution.js +++ b/tests/baselines/reference/overloadResolution.js @@ -98,8 +98,7 @@ var s = fn5((n) => n.substr(0)); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SomeBase = (function () { function SomeBase() { diff --git a/tests/baselines/reference/overloadResolutionClassConstructors.js b/tests/baselines/reference/overloadResolutionClassConstructors.js index fc7dbd9cebe..14306b7873b 100644 --- a/tests/baselines/reference/overloadResolutionClassConstructors.js +++ b/tests/baselines/reference/overloadResolutionClassConstructors.js @@ -105,8 +105,7 @@ new fn5((n) => n.blah); // Error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SomeBase = (function () { function SomeBase() { diff --git a/tests/baselines/reference/overloadResolutionConstructors.js b/tests/baselines/reference/overloadResolutionConstructors.js index b3c2b2ef764..788e6362f86 100644 --- a/tests/baselines/reference/overloadResolutionConstructors.js +++ b/tests/baselines/reference/overloadResolutionConstructors.js @@ -106,8 +106,7 @@ var s = new fn5((n) => n.substr(0)); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SomeBase = (function () { function SomeBase() { diff --git a/tests/baselines/reference/overloadingOnConstants1.js b/tests/baselines/reference/overloadingOnConstants1.js index 4274841d60f..bd08f70498d 100644 --- a/tests/baselines/reference/overloadingOnConstants1.js +++ b/tests/baselines/reference/overloadingOnConstants1.js @@ -29,8 +29,7 @@ var htmlSpanElement2: Derived1 = d2.createElement("span"); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/overloadingOnConstants2.js b/tests/baselines/reference/overloadingOnConstants2.js index 2414ec4eab2..eaec0054f66 100644 --- a/tests/baselines/reference/overloadingOnConstants2.js +++ b/tests/baselines/reference/overloadingOnConstants2.js @@ -31,8 +31,7 @@ var f: C = bar("um", []); // C var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt b/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt index 35837d3233f..45c9f99b691 100644 --- a/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt +++ b/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(18,27): Types of parameters 'x' and 'x' are incompatible. Type 'D' is not assignable to type 'B'. Property 'x' is missing in type 'D'. -tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): error TS2344: Type 'D' does not satisfy the constraint 'A'. +tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,14): error TS2344: Type 'D' does not satisfy the constraint 'A'. ==== tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts (6 errors) ==== @@ -41,7 +41,7 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): ~~~~~~~~~~~~~~~~~~~~~~ var y: G; // error that D does not satisfy constraint, y is of type G, entire call to foo is an error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2344: Type 'D' does not satisfy the constraint 'A'. return y; ~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/overridingPrivateStaticMembers.js b/tests/baselines/reference/overridingPrivateStaticMembers.js index 56ecfec66c0..a155bb1b830 100644 --- a/tests/baselines/reference/overridingPrivateStaticMembers.js +++ b/tests/baselines/reference/overridingPrivateStaticMembers.js @@ -11,8 +11,7 @@ class Derived2 extends Base2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base2 = (function () { function Base2() { diff --git a/tests/baselines/reference/parseErrorInHeritageClause1.js b/tests/baselines/reference/parseErrorInHeritageClause1.js index 66facdeadf0..b6640b64257 100644 --- a/tests/baselines/reference/parseErrorInHeritageClause1.js +++ b/tests/baselines/reference/parseErrorInHeritageClause1.js @@ -6,8 +6,7 @@ class C extends A # { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parser509630.js b/tests/baselines/reference/parser509630.js index 20e00ea01ed..6862eef4a93 100644 --- a/tests/baselines/reference/parser509630.js +++ b/tests/baselines/reference/parser509630.js @@ -10,8 +10,7 @@ class Any extends Type { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Type = (function () { function Type() { diff --git a/tests/baselines/reference/parserAstSpans1.js b/tests/baselines/reference/parserAstSpans1.js index ec88d11b0c9..5de3cb8f9f1 100644 --- a/tests/baselines/reference/parserAstSpans1.js +++ b/tests/baselines/reference/parserAstSpans1.js @@ -223,8 +223,7 @@ class c6 extends c5 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/parserClassDeclaration1.js b/tests/baselines/reference/parserClassDeclaration1.js index 9ef865adb75..f430b8e644a 100644 --- a/tests/baselines/reference/parserClassDeclaration1.js +++ b/tests/baselines/reference/parserClassDeclaration1.js @@ -6,8 +6,7 @@ class C extends A extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserClassDeclaration3.js b/tests/baselines/reference/parserClassDeclaration3.js index 644c4fcb54a..8ea681a668f 100644 --- a/tests/baselines/reference/parserClassDeclaration3.js +++ b/tests/baselines/reference/parserClassDeclaration3.js @@ -6,8 +6,7 @@ class C implements A extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserClassDeclaration4.js b/tests/baselines/reference/parserClassDeclaration4.js index d7cd9ca6cac..2bbbd134ed4 100644 --- a/tests/baselines/reference/parserClassDeclaration4.js +++ b/tests/baselines/reference/parserClassDeclaration4.js @@ -6,8 +6,7 @@ class C extends A implements B extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserClassDeclaration5.js b/tests/baselines/reference/parserClassDeclaration5.js index 4f75eb96668..146cbda9563 100644 --- a/tests/baselines/reference/parserClassDeclaration5.js +++ b/tests/baselines/reference/parserClassDeclaration5.js @@ -6,8 +6,7 @@ class C extends A implements B implements C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserClassDeclaration6.js b/tests/baselines/reference/parserClassDeclaration6.js index a653a7e4042..0f65ad53f07 100644 --- a/tests/baselines/reference/parserClassDeclaration6.js +++ b/tests/baselines/reference/parserClassDeclaration6.js @@ -6,8 +6,7 @@ class C extends A, B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js index 43ebfa2bb0e..3c2f96f54fd 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js @@ -6,8 +6,7 @@ class C extends A, { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js index 732508b8d85..594c4575eab 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js @@ -6,8 +6,7 @@ class C extends A implements { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js index 58f4f4631dc..3d2447e0b8c 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js @@ -6,8 +6,7 @@ class C extends A, implements B, { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserGenericsInTypeContexts1.js b/tests/baselines/reference/parserGenericsInTypeContexts1.js index 5c2369e61c7..9cea884bcfb 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts1.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts1.js @@ -21,8 +21,7 @@ function f2(): F { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserGenericsInTypeContexts2.js b/tests/baselines/reference/parserGenericsInTypeContexts2.js index 487038e1959..b5e5e010d56 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts2.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts2.js @@ -21,8 +21,7 @@ function f2(): F, Y>> { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/parserRealSource10.js b/tests/baselines/reference/parserRealSource10.js index 4c241abba0e..f184db9173c 100644 --- a/tests/baselines/reference/parserRealSource10.js +++ b/tests/baselines/reference/parserRealSource10.js @@ -461,8 +461,7 @@ module TypeScript { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// var TypeScript; diff --git a/tests/baselines/reference/parserRealSource11.js b/tests/baselines/reference/parserRealSource11.js index c6a08062820..4091eb290d1 100644 --- a/tests/baselines/reference/parserRealSource11.js +++ b/tests/baselines/reference/parserRealSource11.js @@ -2370,8 +2370,7 @@ module TypeScript { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// var TypeScript; diff --git a/tests/baselines/reference/parserharness.js b/tests/baselines/reference/parserharness.js index 4e22c804ab6..296aae05fad 100644 --- a/tests/baselines/reference/parserharness.js +++ b/tests/baselines/reference/parserharness.js @@ -2099,8 +2099,7 @@ module Harness { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// diff --git a/tests/baselines/reference/primitiveMembers.js b/tests/baselines/reference/primitiveMembers.js index a49d6f7ee1c..60ae4b79dec 100644 --- a/tests/baselines/reference/primitiveMembers.js +++ b/tests/baselines/reference/primitiveMembers.js @@ -35,8 +35,7 @@ class foo extends baz { public bar(){ return undefined}; } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x = 5; var r = /yo/; diff --git a/tests/baselines/reference/privacyClass.js b/tests/baselines/reference/privacyClass.js index 4d6d0a72e4a..f632ea8b26f 100644 --- a/tests/baselines/reference/privacyClass.js +++ b/tests/baselines/reference/privacyClass.js @@ -131,8 +131,7 @@ export class glo_C12_public extends glo_c_private implements glo_i_private, glo var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var m1; (function (m1) { diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js index 044c30f3797..a3ddd387883 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js @@ -101,8 +101,7 @@ class publicClassExtendingPublicClassInGlobal extends publicClassInGlobal { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var publicModule; (function (publicModule) { @@ -288,8 +287,7 @@ exports.publicClassExtendingFromPrivateModuleClass = publicClassExtendingFromPri var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var publicModuleInGlobal; (function (publicModuleInGlobal) { diff --git a/tests/baselines/reference/privacyGloClass.js b/tests/baselines/reference/privacyGloClass.js index 58877eae167..01eff312739 100644 --- a/tests/baselines/reference/privacyGloClass.js +++ b/tests/baselines/reference/privacyGloClass.js @@ -64,8 +64,7 @@ class glo_C11_public extends glo_c_public implements glo_i_public { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var m1; (function (m1) { diff --git a/tests/baselines/reference/privateAccessInSubclass1.js b/tests/baselines/reference/privateAccessInSubclass1.js index 7004a535952..b22af20af37 100644 --- a/tests/baselines/reference/privateAccessInSubclass1.js +++ b/tests/baselines/reference/privateAccessInSubclass1.js @@ -13,8 +13,7 @@ class D extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.js b/tests/baselines/reference/privateInstanceMemberAccessibility.js index 4158ef6a8f7..ac2f44ee5d9 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.js +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.js @@ -17,8 +17,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.js b/tests/baselines/reference/privateStaticMemberAccessibility.js index 013c606f829..0b9be3b69ff 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.js +++ b/tests/baselines/reference/privateStaticMemberAccessibility.js @@ -12,8 +12,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js index 3db3a636c7d..b67ca77dc26 100644 --- a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js +++ b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js @@ -19,8 +19,7 @@ module D { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index 656b6e1f2a2..bafcc39f48d 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index 656b6e1f2a2..bafcc39f48d 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js index 1ce3452dbed..bab996e07a4 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js @@ -1,8 +1,7 @@ var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var m2; (function (m2) { diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js index 1ce3452dbed..bab996e07a4 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js @@ -1,8 +1,7 @@ var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var m2; (function (m2) { diff --git a/tests/baselines/reference/project/prologueEmit/amd/out.js b/tests/baselines/reference/project/prologueEmit/amd/out.js index e621c38f984..fb0ca5dfac0 100644 --- a/tests/baselines/reference/project/prologueEmit/amd/out.js +++ b/tests/baselines/reference/project/prologueEmit/amd/out.js @@ -4,8 +4,7 @@ var _this = this; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // class inheritance to ensure __extends is emitted var m; diff --git a/tests/baselines/reference/project/prologueEmit/node/out.js b/tests/baselines/reference/project/prologueEmit/node/out.js index e621c38f984..fb0ca5dfac0 100644 --- a/tests/baselines/reference/project/prologueEmit/node/out.js +++ b/tests/baselines/reference/project/prologueEmit/node/out.js @@ -4,8 +4,7 @@ var _this = this; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // class inheritance to ensure __extends is emitted var m; diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js index b1f4dd64ef2..bdf2edefcb0 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js @@ -2,8 +2,7 @@ var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var ClassC = (function (_super) { __extends(ClassC, _super); diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js index b1f4dd64ef2..bdf2edefcb0 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js @@ -2,8 +2,7 @@ var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var ClassC = (function (_super) { __extends(ClassC, _super); diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index b01825c8ad9..27e7df62ab1 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4768, 1), Decl(lib.d.ts, 4854, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4773, 22), Decl(lib.d.ts, 4780, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/propertiesAndIndexers.js b/tests/baselines/reference/propertiesAndIndexers.js index f67a9d89249..b7a39ae2330 100644 --- a/tests/baselines/reference/propertiesAndIndexers.js +++ b/tests/baselines/reference/propertiesAndIndexers.js @@ -55,8 +55,7 @@ var c: { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var P = (function () { function P() { diff --git a/tests/baselines/reference/propertyAccess.js b/tests/baselines/reference/propertyAccess.js index 1e6ef5c1d6d..ed004b332cb 100644 --- a/tests/baselines/reference/propertyAccess.js +++ b/tests/baselines/reference/propertyAccess.js @@ -154,8 +154,7 @@ var x3: A; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js index dc4c30d9165..35c279ba0ed 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js @@ -86,8 +86,7 @@ var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, er var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js index 7e935609e36..24c3fc50501 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js @@ -61,8 +61,7 @@ var r4 = b.foo(new B()); // valid call to an invalid function var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js index f871ce553b7..37b8240b9ac 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js @@ -48,8 +48,7 @@ var r4 = b.foo(new B()); // error after constraints above made illegal, doesn't var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js index 45f001c65fb..ce7bc5d0b40 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js @@ -24,8 +24,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B() { diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js index 10276f8ac85..e47e7e5a7d5 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js @@ -98,8 +98,7 @@ d4.x; // Error, neither within their declaring class nor class var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js index 1a5b7489910..0140e61406c 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js @@ -17,8 +17,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.js b/tests/baselines/reference/protectedInstanceMemberAccessibility.js index 7560c5c89ca..ff4ae952249 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.js +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.js @@ -48,8 +48,7 @@ class C extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/protectedMembers.js b/tests/baselines/reference/protectedMembers.js index 33b6e2ebde2..f86818b6e65 100644 --- a/tests/baselines/reference/protectedMembers.js +++ b/tests/baselines/reference/protectedMembers.js @@ -120,8 +120,7 @@ class B3 extends A3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Class with protected members var C1 = (function () { diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js index 1bd102694d4..9edd43ad52e 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js @@ -47,8 +47,7 @@ Derived3.x; // Error, neither within their declaring class nor classes deriv var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js index c82c67b7003..5a8b07df371 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js @@ -25,8 +25,7 @@ class Derived2 extends Derived1 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt index 21bf243dfcb..e6929df9bae 100644 --- a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt +++ b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts(5,26): error TS2305: Module 'Alpha' has no exported member 'x'. +tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts(5,20): error TS2507: Type 'number' is not a constructor function type. ==== tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class- } class Beta extends Alpha.x { - ~ -!!! error TS2305: Module 'Alpha' has no exported member 'x'. + ~~~~~~~ +!!! error TS2507: Type 'number' is not a constructor function type. } \ No newline at end of file diff --git a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js index 8b071cb6b52..b0079c2f45b 100644 --- a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js +++ b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js @@ -10,8 +10,7 @@ class Beta extends Alpha.x { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Alpha; (function (Alpha) { diff --git a/tests/baselines/reference/recursiveBaseCheck.errors.txt b/tests/baselines/reference/recursiveBaseCheck.errors.txt index 06915b6b430..0ada6976a83 100644 --- a/tests/baselines/reference/recursiveBaseCheck.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck.errors.txt @@ -1,19 +1,31 @@ -tests/cases/compiler/recursiveBaseCheck.ts(2,11): error TS2310: Type 'C' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck.ts(2,11): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(4,18): error TS2506: 'B' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(6,18): error TS2506: 'A' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(8,18): error TS2506: 'AmChart' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(10,18): error TS2506: 'D' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/recursiveBaseCheck.ts (1 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck.ts (5 errors) ==== declare module Module { class C extends D { ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. } export class B extends Module.C { + ~ +!!! error TS2506: 'B' is referenced directly or indirectly in its own base expression. } export class A extends Module.B { + ~ +!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. } export class AmChart extends Module.A { + ~~~~~~~ +!!! error TS2506: 'AmChart' is referenced directly or indirectly in its own base expression. } export class D extends AmChart { + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. } export class E extends Module.D { } diff --git a/tests/baselines/reference/recursiveBaseCheck2.errors.txt b/tests/baselines/reference/recursiveBaseCheck2.errors.txt index 1a39f811912..31eb1104003 100644 --- a/tests/baselines/reference/recursiveBaseCheck2.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck2.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/recursiveBaseCheck2.ts(2,18): error TS2310: Type 'b2CircleShape' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck2.ts(2,18): error TS2506: 'b2CircleShape' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck2.ts(4,18): error TS2506: 'b2Shape' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/recursiveBaseCheck2.ts (1 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck2.ts (2 errors) ==== declare module Box2D.Collision.Shapes { export class b2CircleShape extends b2Shape { ~~~~~~~~~~~~~ -!!! error TS2310: Type 'b2CircleShape' recursively references itself as a base type. +!!! error TS2506: 'b2CircleShape' is referenced directly or indirectly in its own base expression. } export class b2Shape extends Box2D.Collision.Shapes.b2CircleShape { + ~~~~~~~ +!!! error TS2506: 'b2Shape' is referenced directly or indirectly in its own base expression. } } declare module Box2D.Dynamics { diff --git a/tests/baselines/reference/recursiveBaseCheck3.errors.txt b/tests/baselines/reference/recursiveBaseCheck3.errors.txt index fe955b420ee..97f7cadc3d6 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck3.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/recursiveBaseCheck3.ts(1,7): error TS2310: Type 'A' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck3.ts(1,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck3.ts(2,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck3.ts(4,9): error TS2339: Property 'blah' does not exist on type 'C<{}>'. -==== tests/cases/compiler/recursiveBaseCheck3.ts (2 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck3.ts (3 errors) ==== class A extends C { } ~ -!!! error TS2310: Type 'A' recursively references itself as a base type. +!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. class C extends A { } + ~ +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. (new C).blah; ~~~~ diff --git a/tests/baselines/reference/recursiveBaseCheck3.js b/tests/baselines/reference/recursiveBaseCheck3.js index 6c1cd918779..aeb0d70240f 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.js +++ b/tests/baselines/reference/recursiveBaseCheck3.js @@ -8,8 +8,7 @@ class C extends A { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function (_super) { __extends(A, _super); diff --git a/tests/baselines/reference/recursiveBaseCheck4.errors.txt b/tests/baselines/reference/recursiveBaseCheck4.errors.txt index 4417b998871..5616523d14e 100644 --- a/tests/baselines/reference/recursiveBaseCheck4.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/recursiveBaseCheck4.ts(1,7): error TS2310: Type 'M' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck4.ts(1,7): error TS2506: 'M' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck4.ts(2,9): error TS2339: Property 'blah' does not exist on type 'M<{}>'. ==== tests/cases/compiler/recursiveBaseCheck4.ts (2 errors) ==== class M extends M { } ~ -!!! error TS2310: Type 'M' recursively references itself as a base type. +!!! error TS2506: 'M' is referenced directly or indirectly in its own base expression. (new M).blah; ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'M<{}>'. \ No newline at end of file diff --git a/tests/baselines/reference/recursiveBaseCheck4.js b/tests/baselines/reference/recursiveBaseCheck4.js index 1abb6731263..2e4a745a703 100644 --- a/tests/baselines/reference/recursiveBaseCheck4.js +++ b/tests/baselines/reference/recursiveBaseCheck4.js @@ -6,8 +6,7 @@ class M extends M { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M = (function (_super) { __extends(M, _super); diff --git a/tests/baselines/reference/recursiveBaseCheck6.errors.txt b/tests/baselines/reference/recursiveBaseCheck6.errors.txt index 280f50b7a77..6d453da425f 100644 --- a/tests/baselines/reference/recursiveBaseCheck6.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/recursiveBaseCheck6.ts(1,7): error TS2310: Type 'S18
' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck6.ts(1,7): error TS2506: 'S18' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck6.ts(2,13): error TS2339: Property 'blah' does not exist on type 'S18<{}>'. ==== tests/cases/compiler/recursiveBaseCheck6.ts (2 errors) ==== class S18 extends S18<{ S19: A; }>{ } ~~~ -!!! error TS2310: Type 'S18' recursively references itself as a base type. +!!! error TS2506: 'S18' is referenced directly or indirectly in its own base expression. (new S18()).blah; ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'S18<{}>'. \ No newline at end of file diff --git a/tests/baselines/reference/recursiveBaseCheck6.js b/tests/baselines/reference/recursiveBaseCheck6.js index 7fb9b444650..13b4944e96f 100644 --- a/tests/baselines/reference/recursiveBaseCheck6.js +++ b/tests/baselines/reference/recursiveBaseCheck6.js @@ -6,8 +6,7 @@ class S18 extends S18<{ S19: A; }>{ } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var S18 = (function (_super) { __extends(S18, _super); diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation1.js b/tests/baselines/reference/recursiveBaseConstructorCreation1.js index d0fc83b30f2..d14a78ed908 100644 --- a/tests/baselines/reference/recursiveBaseConstructorCreation1.js +++ b/tests/baselines/reference/recursiveBaseConstructorCreation1.js @@ -10,8 +10,7 @@ var x = new C2(); // Valid var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js index 214c543b836..224c13e7765 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js @@ -13,8 +13,7 @@ export class MemberNameArray extends MemberName { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var a = new TypeScript2.MemberNameArray(); var TypeScript2; diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js b/tests/baselines/reference/recursiveClassReferenceTest.js index e9339fec4df..0e884b94e8e 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js +++ b/tests/baselines/reference/recursiveClassReferenceTest.js @@ -108,8 +108,7 @@ module Sample.Thing.Languages.PlainText { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Sample; (function (Sample) { diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index 5573bdd8de8..734906688fd 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js.map +++ b/tests/baselines/reference/recursiveClassReferenceTest.js.map @@ -1,2 +1,2 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":["Sample","Sample.Actions","Sample.Actions.Thing","Sample.Actions.Thing.Find","Sample.Actions.Thing.Find.StartFindAction","Sample.Actions.Thing.Find.StartFindAction.constructor","Sample.Actions.Thing.Find.StartFindAction.getId","Sample.Actions.Thing.Find.StartFindAction.run","Sample.Thing","Sample.Thing.Widgets","Sample.Thing.Widgets.FindWidget","Sample.Thing.Widgets.FindWidget.constructor","Sample.Thing.Widgets.FindWidget.gar","Sample.Thing.Widgets.FindWidget.getDomNode","Sample.Thing.Widgets.FindWidget.destroy","AbstractMode","AbstractMode.constructor","AbstractMode.getInitialState","Sample.Thing.Languages","Sample.Thing.Languages.PlainText","Sample.Thing.Languages.PlainText.State","Sample.Thing.Languages.PlainText.State.constructor","Sample.Thing.Languages.PlainText.State.clone","Sample.Thing.Languages.PlainText.State.equals","Sample.Thing.Languages.PlainText.State.getMode","Sample.Thing.Languages.PlainText.Mode","Sample.Thing.Languages.PlainText.Mode.constructor","Sample.Thing.Languages.PlainText.Mode.getInitialState"],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAACA,IAAAA,OAAOA,CAUpBA;IAVaA,WAAAA,OAAOA;QAACC,IAAAA,KAAKA,CAU1BA;QAVqBA,WAAAA,OAAKA;YAACC,IAAAA,IAAIA,CAU/BA;YAV2BA,WAAAA,IAAIA,EAACA,CAACA;gBACjCC;oBAAAC;oBAQAC,CAACA;oBANOD,+BAAKA,GAAZA,cAAiBE,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAExBF,6BAAGA,GAAVA,UAAWA,KAA6BA;wBAEvCG,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBACFH,sBAACA;gBAADA,CAACA,AARDD,IAQCA;gBARYA,oBAAeA,kBAQ3BA,CAAAA;YACFA,CAACA,EAV2BD,IAAIA,GAAJA,YAAIA,KAAJA,YAAIA,QAU/BA;QAADA,CAACA,EAVqBD,KAAKA,GAALA,aAAKA,KAALA,aAAKA,QAU1BA;IAADA,CAACA,EAVaD,OAAOA,GAAPA,cAAOA,KAAPA,cAAOA,QAUpBA;AAADA,CAACA,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,IAAO,MAAM,CAoBZ;AApBD,WAAO,MAAM;IAACA,IAAAA,KAAKA,CAoBlBA;IApBaA,WAAAA,KAAKA;QAACQ,IAAAA,OAAOA,CAoB1BA;QApBmBA,WAAAA,OAAOA,EAACA,CAACA;YAC5BC;gBAKCC,oBAAoBA,SAAkCA;oBAAlCC,cAASA,GAATA,SAASA,CAAyBA;oBAD9CA,YAAOA,GAAOA,IAAIA,CAACA;oBAGvBA,AADAA,aAAaA;oBACbA,SAASA,CAACA,SAASA,CAACA,WAAWA,EAAEA,IAAIA,CAACA,CAACA;gBAC3CA,CAACA;gBANMD,wBAAGA,GAAVA,UAAWA,MAAyCA,IAAIE,EAAEA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAAAA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,CAACA;gBAAAA,CAACA,CAAAA,CAACA;gBAQlFF,+BAAUA,GAAjBA;oBACCG,MAAMA,CAACA,OAAOA,CAACA;gBAChBA,CAACA;gBAEMH,4BAAOA,GAAdA;gBAEAI,CAACA;gBAEFJ,iBAACA;YAADA,CAACA,AAlBDD,IAkBCA;YAlBYA,kBAAUA,aAkBtBA,CAAAA;QACFA,CAACA,EApBmBD,OAAOA,GAAPA,aAAOA,KAAPA,aAAOA,QAoB1BA;IAADA,CAACA,EApBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAoBlBA;AAADA,CAACA,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAAe;IAAuFC,CAACA;IAA3CD,sCAAeA,GAAtBA,cAAmCE,MAAMA,CAACA,IAAIA,CAACA,CAAAA,CAACA;IAACF,mBAACA;AAADA,CAACA,AAAxF,IAAwF;AASxF,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM;IAACf,IAAAA,KAAKA,CAwBlBA;IAxBaA,WAAAA,KAAKA;QAACQ,IAAAA,SAASA,CAwB5BA;QAxBmBA,WAAAA,SAASA;YAACU,IAAAA,SAASA,CAwBtCA;YAxB6BA,WAAAA,SAASA,EAACA,CAACA;gBAExCC;oBACOC,eAAoBA,IAAWA;wBAAXC,SAAIA,GAAJA,IAAIA,CAAOA;oBAAIA,CAACA;oBACnCD,qBAAKA,GAAZA;wBACCE,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBAEMF,sBAAMA,GAAbA,UAAcA,KAAYA;wBACzBG,MAAMA,CAACA,IAAIA,KAAKA,KAAKA,CAACA;oBACvBA,CAACA;oBAEMH,uBAAOA,GAAdA,cAA0BI,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBACzCJ,YAACA;gBAADA,CAACA,AAXDD,IAWCA;gBAXYA,eAAKA,QAWjBA,CAAAA;gBAEDA;oBAA0BM,wBAAYA;oBAAtCA;wBAA0BC,8BAAYA;oBAQtCA,CAACA;oBANAD,aAAaA;oBACNA,8BAAeA,GAAtBA;wBACCE,MAAMA,CAACA,IAAIA,KAAKA,CAACA,IAAIA,CAACA,CAACA;oBACxBA,CAACA;oBAGFF,WAACA;gBAADA,CAACA,AARDN,EAA0BA,YAAYA,EAQrCA;gBARYA,cAAIA,OAQhBA,CAAAA;YACFA,CAACA,EAxB6BD,SAASA,GAATA,mBAASA,KAATA,mBAASA,QAwBtCA;QAADA,CAACA,EAxBmBV,SAASA,GAATA,eAASA,KAATA,eAASA,QAwB5BA;IAADA,CAACA,EAxBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAwBlBA;AAADA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file +{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":["Sample","Sample.Actions","Sample.Actions.Thing","Sample.Actions.Thing.Find","Sample.Actions.Thing.Find.StartFindAction","Sample.Actions.Thing.Find.StartFindAction.constructor","Sample.Actions.Thing.Find.StartFindAction.getId","Sample.Actions.Thing.Find.StartFindAction.run","Sample.Thing","Sample.Thing.Widgets","Sample.Thing.Widgets.FindWidget","Sample.Thing.Widgets.FindWidget.constructor","Sample.Thing.Widgets.FindWidget.gar","Sample.Thing.Widgets.FindWidget.getDomNode","Sample.Thing.Widgets.FindWidget.destroy","AbstractMode","AbstractMode.constructor","AbstractMode.getInitialState","Sample.Thing.Languages","Sample.Thing.Languages.PlainText","Sample.Thing.Languages.PlainText.State","Sample.Thing.Languages.PlainText.State.constructor","Sample.Thing.Languages.PlainText.State.clone","Sample.Thing.Languages.PlainText.State.equals","Sample.Thing.Languages.PlainText.State.getMode","Sample.Thing.Languages.PlainText.Mode","Sample.Thing.Languages.PlainText.Mode.constructor","Sample.Thing.Languages.PlainText.Mode.getInitialState"],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAACA,IAAAA,OAAOA,CAUpBA;IAVaA,WAAAA,OAAOA;QAACC,IAAAA,KAAKA,CAU1BA;QAVqBA,WAAAA,OAAKA;YAACC,IAAAA,IAAIA,CAU/BA;YAV2BA,WAAAA,IAAIA,EAACA,CAACA;gBACjCC;oBAAAC;oBAQAC,CAACA;oBANOD,+BAAKA,GAAZA,cAAiBE,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAExBF,6BAAGA,GAAVA,UAAWA,KAA6BA;wBAEvCG,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBACFH,sBAACA;gBAADA,CAACA,AARDD,IAQCA;gBARYA,oBAAeA,kBAQ3BA,CAAAA;YACFA,CAACA,EAV2BD,IAAIA,GAAJA,YAAIA,KAAJA,YAAIA,QAU/BA;QAADA,CAACA,EAVqBD,KAAKA,GAALA,aAAKA,KAALA,aAAKA,QAU1BA;IAADA,CAACA,EAVaD,OAAOA,GAAPA,cAAOA,KAAPA,cAAOA,QAUpBA;AAADA,CAACA,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,IAAO,MAAM,CAoBZ;AApBD,WAAO,MAAM;IAACA,IAAAA,KAAKA,CAoBlBA;IApBaA,WAAAA,KAAKA;QAACQ,IAAAA,OAAOA,CAoB1BA;QApBmBA,WAAAA,OAAOA,EAACA,CAACA;YAC5BC;gBAKCC,oBAAoBA,SAAkCA;oBAAlCC,cAASA,GAATA,SAASA,CAAyBA;oBAD9CA,YAAOA,GAAOA,IAAIA,CAACA;oBAGvBA,AADAA,aAAaA;oBACbA,SAASA,CAACA,SAASA,CAACA,WAAWA,EAAEA,IAAIA,CAACA,CAACA;gBAC3CA,CAACA;gBANMD,wBAAGA,GAAVA,UAAWA,MAAyCA,IAAIE,EAAEA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAAAA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,CAACA;gBAAAA,CAACA,CAAAA,CAACA;gBAQlFF,+BAAUA,GAAjBA;oBACCG,MAAMA,CAACA,OAAOA,CAACA;gBAChBA,CAACA;gBAEMH,4BAAOA,GAAdA;gBAEAI,CAACA;gBAEFJ,iBAACA;YAADA,CAACA,AAlBDD,IAkBCA;YAlBYA,kBAAUA,aAkBtBA,CAAAA;QACFA,CAACA,EApBmBD,OAAOA,GAAPA,aAAOA,KAAPA,aAAOA,QAoB1BA;IAADA,CAACA,EApBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAoBlBA;AAADA,CAACA,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAAe;IAAuFC,CAACA;IAA3CD,sCAAeA,GAAtBA,cAAmCE,MAAMA,CAACA,IAAIA,CAACA,CAAAA,CAACA;IAACF,mBAACA;AAADA,CAACA,AAAxF,IAAwF;AASxF,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM;IAACf,IAAAA,KAAKA,CAwBlBA;IAxBaA,WAAAA,KAAKA;QAACQ,IAAAA,SAASA,CAwB5BA;QAxBmBA,WAAAA,SAASA;YAACU,IAAAA,SAASA,CAwBtCA;YAxB6BA,WAAAA,SAASA,EAACA,CAACA;gBAExCC;oBACOC,eAAoBA,IAAWA;wBAAXC,SAAIA,GAAJA,IAAIA,CAAOA;oBAAIA,CAACA;oBACnCD,qBAAKA,GAAZA;wBACCE,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBAEMF,sBAAMA,GAAbA,UAAcA,KAAYA;wBACzBG,MAAMA,CAACA,IAAIA,KAAKA,KAAKA,CAACA;oBACvBA,CAACA;oBAEMH,uBAAOA,GAAdA,cAA0BI,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBACzCJ,YAACA;gBAADA,CAACA,AAXDD,IAWCA;gBAXYA,eAAKA,QAWjBA,CAAAA;gBAEDA;oBAA0BM,wBAAYA;oBAAtCA;wBAA0BC,8BAAYA;oBAQtCA,CAACA;oBANAD,aAAaA;oBACNA,8BAAeA,GAAtBA;wBACCE,MAAMA,CAACA,IAAIA,KAAKA,CAACA,IAAIA,CAACA,CAACA;oBACxBA,CAACA;oBAGFF,WAACA;gBAADA,CAACA,AARDN,EAA0BA,YAAYA,EAQrCA;gBARYA,cAAIA,OAQhBA,CAAAA;YACFA,CAACA,EAxB6BD,SAASA,GAATA,mBAASA,KAATA,mBAASA,QAwBtCA;QAADA,CAACA,EAxBmBV,SAASA,GAATA,eAASA,KAATA,eAASA,QAwB5BA;IAADA,CAACA,EAxBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAwBlBA;AAADA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index 67031d420ea..8f45e0ea715 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -29,8 +29,7 @@ sourceFile:recursiveClassReferenceTest.ts >>>var __extends = (this && this.__extends) || function (d, b) { >>> for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; >>> function __() { this.constructor = d; } ->>> __.prototype = b.prototype; ->>> d.prototype = new __(); +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); >>>}; >>>var Sample; 1 > @@ -82,10 +81,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(9, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(9, 5) Source(32, 8) + SourceIndex(0) -3 >Emitted(9, 11) Source(32, 14) + SourceIndex(0) -4 >Emitted(9, 12) Source(42, 2) + SourceIndex(0) +1 >Emitted(8, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(8, 5) Source(32, 8) + SourceIndex(0) +3 >Emitted(8, 11) Source(32, 14) + SourceIndex(0) +4 >Emitted(8, 12) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -94,9 +93,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 >module 3 > Sample -1->Emitted(10, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(10, 12) Source(32, 8) + SourceIndex(0) -3 >Emitted(10, 18) Source(32, 14) + SourceIndex(0) +1->Emitted(9, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(9, 12) Source(32, 8) + SourceIndex(0) +3 >Emitted(9, 18) Source(32, 14) + SourceIndex(0) --- >>> var Actions; 1 >^^^^ @@ -118,10 +117,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(11, 5) Source(32, 15) + SourceIndex(0) name (Sample) -2 >Emitted(11, 9) Source(32, 15) + SourceIndex(0) name (Sample) -3 >Emitted(11, 16) Source(32, 22) + SourceIndex(0) name (Sample) -4 >Emitted(11, 17) Source(42, 2) + SourceIndex(0) name (Sample) +1 >Emitted(10, 5) Source(32, 15) + SourceIndex(0) name (Sample) +2 >Emitted(10, 9) Source(32, 15) + SourceIndex(0) name (Sample) +3 >Emitted(10, 16) Source(32, 22) + SourceIndex(0) name (Sample) +4 >Emitted(10, 17) Source(42, 2) + SourceIndex(0) name (Sample) --- >>> (function (Actions) { 1->^^^^ @@ -130,9 +129,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Actions -1->Emitted(12, 5) Source(32, 15) + SourceIndex(0) name (Sample) -2 >Emitted(12, 16) Source(32, 15) + SourceIndex(0) name (Sample) -3 >Emitted(12, 23) Source(32, 22) + SourceIndex(0) name (Sample) +1->Emitted(11, 5) Source(32, 15) + SourceIndex(0) name (Sample) +2 >Emitted(11, 16) Source(32, 15) + SourceIndex(0) name (Sample) +3 >Emitted(11, 23) Source(32, 22) + SourceIndex(0) name (Sample) --- >>> var Thing; 1 >^^^^^^^^ @@ -154,10 +153,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(13, 9) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -2 >Emitted(13, 13) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -3 >Emitted(13, 18) Source(32, 28) + SourceIndex(0) name (Sample.Actions) -4 >Emitted(13, 19) Source(42, 2) + SourceIndex(0) name (Sample.Actions) +1 >Emitted(12, 9) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +2 >Emitted(12, 13) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +3 >Emitted(12, 18) Source(32, 28) + SourceIndex(0) name (Sample.Actions) +4 >Emitted(12, 19) Source(42, 2) + SourceIndex(0) name (Sample.Actions) --- >>> (function (Thing_1) { 1->^^^^^^^^ @@ -166,9 +165,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(14, 9) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -2 >Emitted(14, 20) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -3 >Emitted(14, 27) Source(32, 28) + SourceIndex(0) name (Sample.Actions) +1->Emitted(13, 9) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +2 >Emitted(13, 20) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +3 >Emitted(13, 27) Source(32, 28) + SourceIndex(0) name (Sample.Actions) --- >>> var Find; 1 >^^^^^^^^^^^^ @@ -190,10 +189,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(15, 13) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -2 >Emitted(15, 17) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -3 >Emitted(15, 21) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) -4 >Emitted(15, 22) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing) +1 >Emitted(14, 13) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +2 >Emitted(14, 17) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +3 >Emitted(14, 21) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) +4 >Emitted(14, 22) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing) --- >>> (function (Find) { 1->^^^^^^^^^^^^ @@ -207,24 +206,24 @@ sourceFile:recursiveClassReferenceTest.ts 3 > Find 4 > 5 > { -1->Emitted(16, 13) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -2 >Emitted(16, 24) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -3 >Emitted(16, 28) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) -4 >Emitted(16, 30) Source(32, 34) + SourceIndex(0) name (Sample.Actions.Thing) -5 >Emitted(16, 31) Source(32, 35) + SourceIndex(0) name (Sample.Actions.Thing) +1->Emitted(15, 13) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +2 >Emitted(15, 24) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +3 >Emitted(15, 28) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) +4 >Emitted(15, 30) Source(32, 34) + SourceIndex(0) name (Sample.Actions.Thing) +5 >Emitted(15, 31) Source(32, 35) + SourceIndex(0) name (Sample.Actions.Thing) --- >>> var StartFindAction = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(17, 17) Source(33, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find) +1->Emitted(16, 17) Source(33, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find) --- >>> function StartFindAction() { 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(18, 21) Source(33, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +1->Emitted(17, 21) Source(33, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) --- >>> } 1->^^^^^^^^^^^^^^^^^^^^ @@ -240,8 +239,8 @@ sourceFile:recursiveClassReferenceTest.ts > } > 2 > } -1->Emitted(19, 21) Source(41, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.constructor) -2 >Emitted(19, 22) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.constructor) +1->Emitted(18, 21) Source(41, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.constructor) +2 >Emitted(18, 22) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.constructor) --- >>> StartFindAction.prototype.getId = function () { return "yo"; }; 1->^^^^^^^^^^^^^^^^^^^^ @@ -264,16 +263,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(20, 21) Source(35, 10) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -2 >Emitted(20, 52) Source(35, 15) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -3 >Emitted(20, 55) Source(35, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -4 >Emitted(20, 69) Source(35, 20) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) -5 >Emitted(20, 75) Source(35, 26) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) -6 >Emitted(20, 76) Source(35, 27) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) -7 >Emitted(20, 80) Source(35, 31) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) -8 >Emitted(20, 81) Source(35, 32) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) -9 >Emitted(20, 82) Source(35, 33) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) -10>Emitted(20, 83) Source(35, 34) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +1->Emitted(19, 21) Source(35, 10) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +2 >Emitted(19, 52) Source(35, 15) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +3 >Emitted(19, 55) Source(35, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +4 >Emitted(19, 69) Source(35, 20) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +5 >Emitted(19, 75) Source(35, 26) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +6 >Emitted(19, 76) Source(35, 27) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +7 >Emitted(19, 80) Source(35, 31) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +8 >Emitted(19, 81) Source(35, 32) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +9 >Emitted(19, 82) Source(35, 33) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) +10>Emitted(19, 83) Source(35, 34) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.getId) --- >>> StartFindAction.prototype.run = function (Thing) { 1 >^^^^^^^^^^^^^^^^^^^^ @@ -288,11 +287,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > public run( 5 > Thing:Sample.Thing.ICodeThing -1 >Emitted(21, 21) Source(37, 10) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -2 >Emitted(21, 50) Source(37, 13) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -3 >Emitted(21, 53) Source(37, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -4 >Emitted(21, 63) Source(37, 14) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -5 >Emitted(21, 68) Source(37, 43) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +1 >Emitted(20, 21) Source(37, 10) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +2 >Emitted(20, 50) Source(37, 13) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +3 >Emitted(20, 53) Source(37, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +4 >Emitted(20, 63) Source(37, 14) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +5 >Emitted(20, 68) Source(37, 43) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) --- >>> return true; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,11 +306,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > true 5 > ; -1 >Emitted(22, 25) Source(39, 4) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) -2 >Emitted(22, 31) Source(39, 10) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) -3 >Emitted(22, 32) Source(39, 11) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) -4 >Emitted(22, 36) Source(39, 15) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) -5 >Emitted(22, 37) Source(39, 16) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +1 >Emitted(21, 25) Source(39, 4) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +2 >Emitted(21, 31) Source(39, 10) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +3 >Emitted(21, 32) Source(39, 11) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +4 >Emitted(21, 36) Source(39, 15) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +5 >Emitted(21, 37) Source(39, 16) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -320,8 +319,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(23, 21) Source(40, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) -2 >Emitted(23, 22) Source(40, 4) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +1 >Emitted(22, 21) Source(40, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) +2 >Emitted(22, 22) Source(40, 4) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction.run) --- >>> return StartFindAction; 1->^^^^^^^^^^^^^^^^^^^^ @@ -329,8 +328,8 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > 2 > } -1->Emitted(24, 21) Source(41, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -2 >Emitted(24, 43) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +1->Emitted(23, 21) Source(41, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +2 >Emitted(23, 43) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) --- >>> })(); 1 >^^^^^^^^^^^^^^^^ @@ -350,10 +349,10 @@ sourceFile:recursiveClassReferenceTest.ts > return true; > } > } -1 >Emitted(25, 17) Source(41, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -2 >Emitted(25, 18) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) -3 >Emitted(25, 18) Source(33, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find) -4 >Emitted(25, 22) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find) +1 >Emitted(24, 17) Source(41, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +2 >Emitted(24, 18) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find.StartFindAction) +3 >Emitted(24, 18) Source(33, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find) +4 >Emitted(24, 22) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find) --- >>> Find.StartFindAction = StartFindAction; 1->^^^^^^^^^^^^^^^^ @@ -373,10 +372,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } 4 > -1->Emitted(26, 17) Source(33, 15) + SourceIndex(0) name (Sample.Actions.Thing.Find) -2 >Emitted(26, 37) Source(33, 30) + SourceIndex(0) name (Sample.Actions.Thing.Find) -3 >Emitted(26, 55) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find) -4 >Emitted(26, 56) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find) +1->Emitted(25, 17) Source(33, 15) + SourceIndex(0) name (Sample.Actions.Thing.Find) +2 >Emitted(25, 37) Source(33, 30) + SourceIndex(0) name (Sample.Actions.Thing.Find) +3 >Emitted(25, 55) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find) +4 >Emitted(25, 56) Source(41, 3) + SourceIndex(0) name (Sample.Actions.Thing.Find) --- >>> })(Find = Thing_1.Find || (Thing_1.Find = {})); 1->^^^^^^^^^^^^ @@ -408,15 +407,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(27, 13) Source(42, 1) + SourceIndex(0) name (Sample.Actions.Thing.Find) -2 >Emitted(27, 14) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find) -3 >Emitted(27, 16) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -4 >Emitted(27, 20) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) -5 >Emitted(27, 23) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -6 >Emitted(27, 35) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) -7 >Emitted(27, 40) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) -8 >Emitted(27, 52) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) -9 >Emitted(27, 60) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing) +1->Emitted(26, 13) Source(42, 1) + SourceIndex(0) name (Sample.Actions.Thing.Find) +2 >Emitted(26, 14) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing.Find) +3 >Emitted(26, 16) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +4 >Emitted(26, 20) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) +5 >Emitted(26, 23) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +6 >Emitted(26, 35) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) +7 >Emitted(26, 40) Source(32, 29) + SourceIndex(0) name (Sample.Actions.Thing) +8 >Emitted(26, 52) Source(32, 33) + SourceIndex(0) name (Sample.Actions.Thing) +9 >Emitted(26, 60) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing) --- >>> })(Thing = Actions.Thing || (Actions.Thing = {})); 1 >^^^^^^^^ @@ -448,15 +447,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(28, 9) Source(42, 1) + SourceIndex(0) name (Sample.Actions.Thing) -2 >Emitted(28, 10) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing) -3 >Emitted(28, 12) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -4 >Emitted(28, 17) Source(32, 28) + SourceIndex(0) name (Sample.Actions) -5 >Emitted(28, 20) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -6 >Emitted(28, 33) Source(32, 28) + SourceIndex(0) name (Sample.Actions) -7 >Emitted(28, 38) Source(32, 23) + SourceIndex(0) name (Sample.Actions) -8 >Emitted(28, 51) Source(32, 28) + SourceIndex(0) name (Sample.Actions) -9 >Emitted(28, 59) Source(42, 2) + SourceIndex(0) name (Sample.Actions) +1 >Emitted(27, 9) Source(42, 1) + SourceIndex(0) name (Sample.Actions.Thing) +2 >Emitted(27, 10) Source(42, 2) + SourceIndex(0) name (Sample.Actions.Thing) +3 >Emitted(27, 12) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +4 >Emitted(27, 17) Source(32, 28) + SourceIndex(0) name (Sample.Actions) +5 >Emitted(27, 20) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +6 >Emitted(27, 33) Source(32, 28) + SourceIndex(0) name (Sample.Actions) +7 >Emitted(27, 38) Source(32, 23) + SourceIndex(0) name (Sample.Actions) +8 >Emitted(27, 51) Source(32, 28) + SourceIndex(0) name (Sample.Actions) +9 >Emitted(27, 59) Source(42, 2) + SourceIndex(0) name (Sample.Actions) --- >>> })(Actions = Sample.Actions || (Sample.Actions = {})); 1->^^^^ @@ -487,15 +486,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(29, 5) Source(42, 1) + SourceIndex(0) name (Sample.Actions) -2 >Emitted(29, 6) Source(42, 2) + SourceIndex(0) name (Sample.Actions) -3 >Emitted(29, 8) Source(32, 15) + SourceIndex(0) name (Sample) -4 >Emitted(29, 15) Source(32, 22) + SourceIndex(0) name (Sample) -5 >Emitted(29, 18) Source(32, 15) + SourceIndex(0) name (Sample) -6 >Emitted(29, 32) Source(32, 22) + SourceIndex(0) name (Sample) -7 >Emitted(29, 37) Source(32, 15) + SourceIndex(0) name (Sample) -8 >Emitted(29, 51) Source(32, 22) + SourceIndex(0) name (Sample) -9 >Emitted(29, 59) Source(42, 2) + SourceIndex(0) name (Sample) +1->Emitted(28, 5) Source(42, 1) + SourceIndex(0) name (Sample.Actions) +2 >Emitted(28, 6) Source(42, 2) + SourceIndex(0) name (Sample.Actions) +3 >Emitted(28, 8) Source(32, 15) + SourceIndex(0) name (Sample) +4 >Emitted(28, 15) Source(32, 22) + SourceIndex(0) name (Sample) +5 >Emitted(28, 18) Source(32, 15) + SourceIndex(0) name (Sample) +6 >Emitted(28, 32) Source(32, 22) + SourceIndex(0) name (Sample) +7 >Emitted(28, 37) Source(32, 15) + SourceIndex(0) name (Sample) +8 >Emitted(28, 51) Source(32, 22) + SourceIndex(0) name (Sample) +9 >Emitted(28, 59) Source(42, 2) + SourceIndex(0) name (Sample) --- >>>})(Sample || (Sample = {})); 1 > @@ -522,13 +521,13 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(30, 1) Source(42, 1) + SourceIndex(0) name (Sample) -2 >Emitted(30, 2) Source(42, 2) + SourceIndex(0) name (Sample) -3 >Emitted(30, 4) Source(32, 8) + SourceIndex(0) -4 >Emitted(30, 10) Source(32, 14) + SourceIndex(0) -5 >Emitted(30, 15) Source(32, 8) + SourceIndex(0) -6 >Emitted(30, 21) Source(32, 14) + SourceIndex(0) -7 >Emitted(30, 29) Source(42, 2) + SourceIndex(0) +1 >Emitted(29, 1) Source(42, 1) + SourceIndex(0) name (Sample) +2 >Emitted(29, 2) Source(42, 2) + SourceIndex(0) name (Sample) +3 >Emitted(29, 4) Source(32, 8) + SourceIndex(0) +4 >Emitted(29, 10) Source(32, 14) + SourceIndex(0) +5 >Emitted(29, 15) Source(32, 8) + SourceIndex(0) +6 >Emitted(29, 21) Source(32, 14) + SourceIndex(0) +7 >Emitted(29, 29) Source(42, 2) + SourceIndex(0) --- >>>var Sample; 1 > @@ -562,10 +561,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(31, 1) Source(44, 1) + SourceIndex(0) -2 >Emitted(31, 5) Source(44, 8) + SourceIndex(0) -3 >Emitted(31, 11) Source(44, 14) + SourceIndex(0) -4 >Emitted(31, 12) Source(64, 2) + SourceIndex(0) +1 >Emitted(30, 1) Source(44, 1) + SourceIndex(0) +2 >Emitted(30, 5) Source(44, 8) + SourceIndex(0) +3 >Emitted(30, 11) Source(44, 14) + SourceIndex(0) +4 >Emitted(30, 12) Source(64, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -574,9 +573,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 >module 3 > Sample -1->Emitted(32, 1) Source(44, 1) + SourceIndex(0) -2 >Emitted(32, 12) Source(44, 8) + SourceIndex(0) -3 >Emitted(32, 18) Source(44, 14) + SourceIndex(0) +1->Emitted(31, 1) Source(44, 1) + SourceIndex(0) +2 >Emitted(31, 12) Source(44, 8) + SourceIndex(0) +3 >Emitted(31, 18) Source(44, 14) + SourceIndex(0) --- >>> var Thing; 1 >^^^^ @@ -608,10 +607,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(33, 5) Source(44, 15) + SourceIndex(0) name (Sample) -2 >Emitted(33, 9) Source(44, 15) + SourceIndex(0) name (Sample) -3 >Emitted(33, 14) Source(44, 20) + SourceIndex(0) name (Sample) -4 >Emitted(33, 15) Source(64, 2) + SourceIndex(0) name (Sample) +1 >Emitted(32, 5) Source(44, 15) + SourceIndex(0) name (Sample) +2 >Emitted(32, 9) Source(44, 15) + SourceIndex(0) name (Sample) +3 >Emitted(32, 14) Source(44, 20) + SourceIndex(0) name (Sample) +4 >Emitted(32, 15) Source(64, 2) + SourceIndex(0) name (Sample) --- >>> (function (Thing) { 1->^^^^ @@ -621,9 +620,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(34, 5) Source(44, 15) + SourceIndex(0) name (Sample) -2 >Emitted(34, 16) Source(44, 15) + SourceIndex(0) name (Sample) -3 >Emitted(34, 21) Source(44, 20) + SourceIndex(0) name (Sample) +1->Emitted(33, 5) Source(44, 15) + SourceIndex(0) name (Sample) +2 >Emitted(33, 16) Source(44, 15) + SourceIndex(0) name (Sample) +3 >Emitted(33, 21) Source(44, 20) + SourceIndex(0) name (Sample) --- >>> var Widgets; 1->^^^^^^^^ @@ -655,10 +654,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(35, 9) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -2 >Emitted(35, 13) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -3 >Emitted(35, 20) Source(44, 28) + SourceIndex(0) name (Sample.Thing) -4 >Emitted(35, 21) Source(64, 2) + SourceIndex(0) name (Sample.Thing) +1->Emitted(34, 9) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +2 >Emitted(34, 13) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +3 >Emitted(34, 20) Source(44, 28) + SourceIndex(0) name (Sample.Thing) +4 >Emitted(34, 21) Source(64, 2) + SourceIndex(0) name (Sample.Thing) --- >>> (function (Widgets) { 1->^^^^^^^^ @@ -672,18 +671,18 @@ sourceFile:recursiveClassReferenceTest.ts 3 > Widgets 4 > 5 > { -1->Emitted(36, 9) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -2 >Emitted(36, 20) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -3 >Emitted(36, 27) Source(44, 28) + SourceIndex(0) name (Sample.Thing) -4 >Emitted(36, 29) Source(44, 29) + SourceIndex(0) name (Sample.Thing) -5 >Emitted(36, 30) Source(44, 30) + SourceIndex(0) name (Sample.Thing) +1->Emitted(35, 9) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +2 >Emitted(35, 20) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +3 >Emitted(35, 27) Source(44, 28) + SourceIndex(0) name (Sample.Thing) +4 >Emitted(35, 29) Source(44, 29) + SourceIndex(0) name (Sample.Thing) +5 >Emitted(35, 30) Source(44, 30) + SourceIndex(0) name (Sample.Thing) --- >>> var FindWidget = (function () { 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(37, 13) Source(45, 2) + SourceIndex(0) name (Sample.Thing.Widgets) +1->Emitted(36, 13) Source(45, 2) + SourceIndex(0) name (Sample.Thing.Widgets) --- >>> function FindWidget(codeThing) { 1->^^^^^^^^^^^^^^^^ @@ -698,9 +697,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > constructor(private 3 > codeThing: Sample.Thing.ICodeThing -1->Emitted(38, 17) Source(50, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -2 >Emitted(38, 37) Source(50, 23) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -3 >Emitted(38, 46) Source(50, 57) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +1->Emitted(37, 17) Source(50, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +2 >Emitted(37, 37) Source(50, 23) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +3 >Emitted(37, 46) Source(50, 57) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) --- >>> this.codeThing = codeThing; 1->^^^^^^^^^^^^^^^^^^^^ @@ -713,11 +712,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > codeThing 5 > : Sample.Thing.ICodeThing -1->Emitted(39, 21) Source(50, 23) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -2 >Emitted(39, 35) Source(50, 32) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -3 >Emitted(39, 38) Source(50, 23) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -4 >Emitted(39, 47) Source(50, 32) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -5 >Emitted(39, 48) Source(50, 57) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +1->Emitted(38, 21) Source(50, 23) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 >Emitted(38, 35) Source(50, 32) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +3 >Emitted(38, 38) Source(50, 23) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +4 >Emitted(38, 47) Source(50, 32) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +5 >Emitted(38, 48) Source(50, 57) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) --- >>> this.domNode = null; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -730,11 +729,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > :any = 4 > null 5 > ; -1 >Emitted(40, 21) Source(49, 11) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -2 >Emitted(40, 33) Source(49, 18) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -3 >Emitted(40, 36) Source(49, 25) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -4 >Emitted(40, 40) Source(49, 29) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -5 >Emitted(40, 41) Source(49, 30) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +1 >Emitted(39, 21) Source(49, 11) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 >Emitted(39, 33) Source(49, 18) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +3 >Emitted(39, 36) Source(49, 25) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +4 >Emitted(39, 40) Source(49, 29) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +5 >Emitted(39, 41) Source(49, 30) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) --- >>> // scenario 1 1 >^^^^^^^^^^^^^^^^^^^^ @@ -747,9 +746,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > 3 > // scenario 1 -1 >Emitted(41, 21) Source(52, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -2 >Emitted(41, 21) Source(51, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -3 >Emitted(41, 34) Source(51, 20) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +1 >Emitted(40, 21) Source(52, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 >Emitted(40, 21) Source(51, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +3 >Emitted(40, 34) Source(51, 20) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) --- >>> codeThing.addWidget("addWidget", this); 1->^^^^^^^^^^^^^^^^^^^^ @@ -773,16 +772,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > this 9 > ) 10> ; -1->Emitted(42, 21) Source(52, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -2 >Emitted(42, 30) Source(52, 16) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -3 >Emitted(42, 31) Source(52, 17) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -4 >Emitted(42, 40) Source(52, 26) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -5 >Emitted(42, 41) Source(52, 27) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -6 >Emitted(42, 52) Source(52, 38) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -7 >Emitted(42, 54) Source(52, 40) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -8 >Emitted(42, 58) Source(52, 44) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -9 >Emitted(42, 59) Source(52, 45) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -10>Emitted(42, 60) Source(52, 46) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +1->Emitted(41, 21) Source(52, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 >Emitted(41, 30) Source(52, 16) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +3 >Emitted(41, 31) Source(52, 17) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +4 >Emitted(41, 40) Source(52, 26) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +5 >Emitted(41, 41) Source(52, 27) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +6 >Emitted(41, 52) Source(52, 38) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +7 >Emitted(41, 54) Source(52, 40) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +8 >Emitted(41, 58) Source(52, 44) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +9 >Emitted(41, 59) Source(52, 45) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +10>Emitted(41, 60) Source(52, 46) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -791,8 +790,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(43, 17) Source(53, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -2 >Emitted(43, 18) Source(53, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +1 >Emitted(42, 17) Source(53, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 >Emitted(42, 18) Source(53, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) --- >>> FindWidget.prototype.gar = function (runner) { if (true) { 1->^^^^^^^^^^^^^^^^ @@ -821,19 +820,19 @@ sourceFile:recursiveClassReferenceTest.ts 11> ) 12> 13> { -1->Emitted(44, 17) Source(47, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -2 >Emitted(44, 41) Source(47, 13) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -3 >Emitted(44, 44) Source(47, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -4 >Emitted(44, 54) Source(47, 14) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -5 >Emitted(44, 60) Source(47, 55) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -6 >Emitted(44, 64) Source(47, 59) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -7 >Emitted(44, 66) Source(47, 61) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -8 >Emitted(44, 67) Source(47, 62) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -9 >Emitted(44, 68) Source(47, 63) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -10>Emitted(44, 72) Source(47, 67) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -11>Emitted(44, 73) Source(47, 68) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -12>Emitted(44, 74) Source(47, 69) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -13>Emitted(44, 75) Source(47, 70) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +1->Emitted(43, 17) Source(47, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +2 >Emitted(43, 41) Source(47, 13) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +3 >Emitted(43, 44) Source(47, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +4 >Emitted(43, 54) Source(47, 14) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +5 >Emitted(43, 60) Source(47, 55) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +6 >Emitted(43, 64) Source(47, 59) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +7 >Emitted(43, 66) Source(47, 61) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +8 >Emitted(43, 67) Source(47, 62) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +9 >Emitted(43, 68) Source(47, 63) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +10>Emitted(43, 72) Source(47, 67) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +11>Emitted(43, 73) Source(47, 68) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +12>Emitted(43, 74) Source(47, 69) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +13>Emitted(43, 75) Source(47, 70) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) --- >>> return runner(this); 1 >^^^^^^^^^^^^^^^^^^^^ @@ -852,14 +851,14 @@ sourceFile:recursiveClassReferenceTest.ts 6 > this 7 > ) 8 > ; -1 >Emitted(45, 21) Source(47, 70) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -2 >Emitted(45, 27) Source(47, 76) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -3 >Emitted(45, 28) Source(47, 77) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -4 >Emitted(45, 34) Source(47, 83) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -5 >Emitted(45, 35) Source(47, 84) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -6 >Emitted(45, 39) Source(47, 88) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -7 >Emitted(45, 40) Source(47, 89) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -8 >Emitted(45, 41) Source(47, 90) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +1 >Emitted(44, 21) Source(47, 70) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +2 >Emitted(44, 27) Source(47, 76) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +3 >Emitted(44, 28) Source(47, 77) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +4 >Emitted(44, 34) Source(47, 83) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +5 >Emitted(44, 35) Source(47, 84) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +6 >Emitted(44, 39) Source(47, 88) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +7 >Emitted(44, 40) Source(47, 89) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +8 >Emitted(44, 41) Source(47, 90) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) --- >>> } }; 1 >^^^^^^^^^^^^^^^^ @@ -871,10 +870,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > } 3 > 4 > } -1 >Emitted(46, 17) Source(47, 90) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -2 >Emitted(46, 18) Source(47, 91) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -3 >Emitted(46, 19) Source(47, 91) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) -4 >Emitted(46, 20) Source(47, 92) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +1 >Emitted(45, 17) Source(47, 90) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +2 >Emitted(45, 18) Source(47, 91) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +3 >Emitted(45, 19) Source(47, 91) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) +4 >Emitted(45, 20) Source(47, 92) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.gar) --- >>> FindWidget.prototype.getDomNode = function () { 1->^^^^^^^^^^^^^^^^ @@ -891,9 +890,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getDomNode 3 > -1->Emitted(47, 17) Source(55, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -2 >Emitted(47, 48) Source(55, 20) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -3 >Emitted(47, 51) Source(55, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +1->Emitted(46, 17) Source(55, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +2 >Emitted(46, 48) Source(55, 20) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +3 >Emitted(46, 51) Source(55, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) --- >>> return domNode; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -907,11 +906,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > domNode 5 > ; -1 >Emitted(48, 21) Source(56, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) -2 >Emitted(48, 27) Source(56, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) -3 >Emitted(48, 28) Source(56, 11) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) -4 >Emitted(48, 35) Source(56, 18) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) -5 >Emitted(48, 36) Source(56, 19) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +1 >Emitted(47, 21) Source(56, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +2 >Emitted(47, 27) Source(56, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +3 >Emitted(47, 28) Source(56, 11) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +4 >Emitted(47, 35) Source(56, 18) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +5 >Emitted(47, 36) Source(56, 19) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) --- >>> }; 1 >^^^^^^^^^^^^^^^^ @@ -920,8 +919,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(49, 17) Source(57, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) -2 >Emitted(49, 18) Source(57, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +1 >Emitted(48, 17) Source(57, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) +2 >Emitted(48, 18) Source(57, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.getDomNode) --- >>> FindWidget.prototype.destroy = function () { 1->^^^^^^^^^^^^^^^^ @@ -932,9 +931,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > destroy 3 > -1->Emitted(50, 17) Source(59, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -2 >Emitted(50, 45) Source(59, 17) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -3 >Emitted(50, 48) Source(59, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +1->Emitted(49, 17) Source(59, 10) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +2 >Emitted(49, 45) Source(59, 17) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +3 >Emitted(49, 48) Source(59, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) --- >>> }; 1 >^^^^^^^^^^^^^^^^ @@ -944,8 +943,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1 >Emitted(51, 17) Source(61, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.destroy) -2 >Emitted(51, 18) Source(61, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.destroy) +1 >Emitted(50, 17) Source(61, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.destroy) +2 >Emitted(50, 18) Source(61, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.destroy) --- >>> return FindWidget; 1->^^^^^^^^^^^^^^^^ @@ -954,8 +953,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(52, 17) Source(63, 2) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -2 >Emitted(52, 34) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +1->Emitted(51, 17) Source(63, 2) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +2 >Emitted(51, 34) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) --- >>> })(); 1 >^^^^^^^^^^^^ @@ -985,10 +984,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > > } -1 >Emitted(53, 13) Source(63, 2) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -2 >Emitted(53, 14) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) -3 >Emitted(53, 14) Source(45, 2) + SourceIndex(0) name (Sample.Thing.Widgets) -4 >Emitted(53, 18) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets) +1 >Emitted(52, 13) Source(63, 2) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +2 >Emitted(52, 14) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget) +3 >Emitted(52, 14) Source(45, 2) + SourceIndex(0) name (Sample.Thing.Widgets) +4 >Emitted(52, 18) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets) --- >>> Widgets.FindWidget = FindWidget; 1->^^^^^^^^^^^^ @@ -1018,10 +1017,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } 4 > -1->Emitted(54, 13) Source(45, 15) + SourceIndex(0) name (Sample.Thing.Widgets) -2 >Emitted(54, 31) Source(45, 25) + SourceIndex(0) name (Sample.Thing.Widgets) -3 >Emitted(54, 44) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets) -4 >Emitted(54, 45) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets) +1->Emitted(53, 13) Source(45, 15) + SourceIndex(0) name (Sample.Thing.Widgets) +2 >Emitted(53, 31) Source(45, 25) + SourceIndex(0) name (Sample.Thing.Widgets) +3 >Emitted(53, 44) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets) +4 >Emitted(53, 45) Source(63, 3) + SourceIndex(0) name (Sample.Thing.Widgets) --- >>> })(Widgets = Thing.Widgets || (Thing.Widgets = {})); 1->^^^^^^^^ @@ -1063,15 +1062,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(55, 9) Source(64, 1) + SourceIndex(0) name (Sample.Thing.Widgets) -2 >Emitted(55, 10) Source(64, 2) + SourceIndex(0) name (Sample.Thing.Widgets) -3 >Emitted(55, 12) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -4 >Emitted(55, 19) Source(44, 28) + SourceIndex(0) name (Sample.Thing) -5 >Emitted(55, 22) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -6 >Emitted(55, 35) Source(44, 28) + SourceIndex(0) name (Sample.Thing) -7 >Emitted(55, 40) Source(44, 21) + SourceIndex(0) name (Sample.Thing) -8 >Emitted(55, 53) Source(44, 28) + SourceIndex(0) name (Sample.Thing) -9 >Emitted(55, 61) Source(64, 2) + SourceIndex(0) name (Sample.Thing) +1->Emitted(54, 9) Source(64, 1) + SourceIndex(0) name (Sample.Thing.Widgets) +2 >Emitted(54, 10) Source(64, 2) + SourceIndex(0) name (Sample.Thing.Widgets) +3 >Emitted(54, 12) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +4 >Emitted(54, 19) Source(44, 28) + SourceIndex(0) name (Sample.Thing) +5 >Emitted(54, 22) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +6 >Emitted(54, 35) Source(44, 28) + SourceIndex(0) name (Sample.Thing) +7 >Emitted(54, 40) Source(44, 21) + SourceIndex(0) name (Sample.Thing) +8 >Emitted(54, 53) Source(44, 28) + SourceIndex(0) name (Sample.Thing) +9 >Emitted(54, 61) Source(64, 2) + SourceIndex(0) name (Sample.Thing) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1112,15 +1111,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(56, 5) Source(64, 1) + SourceIndex(0) name (Sample.Thing) -2 >Emitted(56, 6) Source(64, 2) + SourceIndex(0) name (Sample.Thing) -3 >Emitted(56, 8) Source(44, 15) + SourceIndex(0) name (Sample) -4 >Emitted(56, 13) Source(44, 20) + SourceIndex(0) name (Sample) -5 >Emitted(56, 16) Source(44, 15) + SourceIndex(0) name (Sample) -6 >Emitted(56, 28) Source(44, 20) + SourceIndex(0) name (Sample) -7 >Emitted(56, 33) Source(44, 15) + SourceIndex(0) name (Sample) -8 >Emitted(56, 45) Source(44, 20) + SourceIndex(0) name (Sample) -9 >Emitted(56, 53) Source(64, 2) + SourceIndex(0) name (Sample) +1 >Emitted(55, 5) Source(64, 1) + SourceIndex(0) name (Sample.Thing) +2 >Emitted(55, 6) Source(64, 2) + SourceIndex(0) name (Sample.Thing) +3 >Emitted(55, 8) Source(44, 15) + SourceIndex(0) name (Sample) +4 >Emitted(55, 13) Source(44, 20) + SourceIndex(0) name (Sample) +5 >Emitted(55, 16) Source(44, 15) + SourceIndex(0) name (Sample) +6 >Emitted(55, 28) Source(44, 20) + SourceIndex(0) name (Sample) +7 >Emitted(55, 33) Source(44, 15) + SourceIndex(0) name (Sample) +8 >Emitted(55, 45) Source(44, 20) + SourceIndex(0) name (Sample) +9 >Emitted(55, 53) Source(64, 2) + SourceIndex(0) name (Sample) --- >>>})(Sample || (Sample = {})); 1 > @@ -1158,13 +1157,13 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(57, 1) Source(64, 1) + SourceIndex(0) name (Sample) -2 >Emitted(57, 2) Source(64, 2) + SourceIndex(0) name (Sample) -3 >Emitted(57, 4) Source(44, 8) + SourceIndex(0) -4 >Emitted(57, 10) Source(44, 14) + SourceIndex(0) -5 >Emitted(57, 15) Source(44, 8) + SourceIndex(0) -6 >Emitted(57, 21) Source(44, 14) + SourceIndex(0) -7 >Emitted(57, 29) Source(64, 2) + SourceIndex(0) +1 >Emitted(56, 1) Source(64, 1) + SourceIndex(0) name (Sample) +2 >Emitted(56, 2) Source(64, 2) + SourceIndex(0) name (Sample) +3 >Emitted(56, 4) Source(44, 8) + SourceIndex(0) +4 >Emitted(56, 10) Source(44, 14) + SourceIndex(0) +5 >Emitted(56, 15) Source(44, 8) + SourceIndex(0) +6 >Emitted(56, 21) Source(44, 14) + SourceIndex(0) +7 >Emitted(56, 29) Source(64, 2) + SourceIndex(0) --- >>>var AbstractMode = (function () { 1-> @@ -1173,13 +1172,13 @@ sourceFile:recursiveClassReferenceTest.ts > >interface IMode { getInitialState(): IState;} > -1->Emitted(58, 1) Source(67, 1) + SourceIndex(0) +1->Emitted(57, 1) Source(67, 1) + SourceIndex(0) --- >>> function AbstractMode() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(59, 5) Source(67, 1) + SourceIndex(0) name (AbstractMode) +1->Emitted(58, 5) Source(67, 1) + SourceIndex(0) name (AbstractMode) --- >>> } 1->^^^^ @@ -1187,8 +1186,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1->class AbstractMode implements IMode { public getInitialState(): IState { return null;} 2 > } -1->Emitted(60, 5) Source(67, 88) + SourceIndex(0) name (AbstractMode.constructor) -2 >Emitted(60, 6) Source(67, 89) + SourceIndex(0) name (AbstractMode.constructor) +1->Emitted(59, 5) Source(67, 88) + SourceIndex(0) name (AbstractMode.constructor) +2 >Emitted(59, 6) Source(67, 89) + SourceIndex(0) name (AbstractMode.constructor) --- >>> AbstractMode.prototype.getInitialState = function () { return null; }; 1->^^^^ @@ -1211,24 +1210,24 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(61, 5) Source(67, 46) + SourceIndex(0) name (AbstractMode) -2 >Emitted(61, 43) Source(67, 61) + SourceIndex(0) name (AbstractMode) -3 >Emitted(61, 46) Source(67, 39) + SourceIndex(0) name (AbstractMode) -4 >Emitted(61, 60) Source(67, 74) + SourceIndex(0) name (AbstractMode.getInitialState) -5 >Emitted(61, 66) Source(67, 80) + SourceIndex(0) name (AbstractMode.getInitialState) -6 >Emitted(61, 67) Source(67, 81) + SourceIndex(0) name (AbstractMode.getInitialState) -7 >Emitted(61, 71) Source(67, 85) + SourceIndex(0) name (AbstractMode.getInitialState) -8 >Emitted(61, 72) Source(67, 86) + SourceIndex(0) name (AbstractMode.getInitialState) -9 >Emitted(61, 73) Source(67, 86) + SourceIndex(0) name (AbstractMode.getInitialState) -10>Emitted(61, 74) Source(67, 87) + SourceIndex(0) name (AbstractMode.getInitialState) +1->Emitted(60, 5) Source(67, 46) + SourceIndex(0) name (AbstractMode) +2 >Emitted(60, 43) Source(67, 61) + SourceIndex(0) name (AbstractMode) +3 >Emitted(60, 46) Source(67, 39) + SourceIndex(0) name (AbstractMode) +4 >Emitted(60, 60) Source(67, 74) + SourceIndex(0) name (AbstractMode.getInitialState) +5 >Emitted(60, 66) Source(67, 80) + SourceIndex(0) name (AbstractMode.getInitialState) +6 >Emitted(60, 67) Source(67, 81) + SourceIndex(0) name (AbstractMode.getInitialState) +7 >Emitted(60, 71) Source(67, 85) + SourceIndex(0) name (AbstractMode.getInitialState) +8 >Emitted(60, 72) Source(67, 86) + SourceIndex(0) name (AbstractMode.getInitialState) +9 >Emitted(60, 73) Source(67, 86) + SourceIndex(0) name (AbstractMode.getInitialState) +10>Emitted(60, 74) Source(67, 87) + SourceIndex(0) name (AbstractMode.getInitialState) --- >>> return AbstractMode; 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^ 1 > 2 > } -1 >Emitted(62, 5) Source(67, 88) + SourceIndex(0) name (AbstractMode) -2 >Emitted(62, 24) Source(67, 89) + SourceIndex(0) name (AbstractMode) +1 >Emitted(61, 5) Source(67, 88) + SourceIndex(0) name (AbstractMode) +2 >Emitted(61, 24) Source(67, 89) + SourceIndex(0) name (AbstractMode) --- >>>})(); 1 > @@ -1240,10 +1239,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 >} 3 > 4 > class AbstractMode implements IMode { public getInitialState(): IState { return null;} } -1 >Emitted(63, 1) Source(67, 88) + SourceIndex(0) name (AbstractMode) -2 >Emitted(63, 2) Source(67, 89) + SourceIndex(0) name (AbstractMode) -3 >Emitted(63, 2) Source(67, 1) + SourceIndex(0) -4 >Emitted(63, 6) Source(67, 89) + SourceIndex(0) +1 >Emitted(62, 1) Source(67, 88) + SourceIndex(0) name (AbstractMode) +2 >Emitted(62, 2) Source(67, 89) + SourceIndex(0) name (AbstractMode) +3 >Emitted(62, 2) Source(67, 1) + SourceIndex(0) +4 >Emitted(62, 6) Source(67, 89) + SourceIndex(0) --- >>>var Sample; 1-> @@ -1288,10 +1287,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(64, 1) Source(76, 1) + SourceIndex(0) -2 >Emitted(64, 5) Source(76, 8) + SourceIndex(0) -3 >Emitted(64, 11) Source(76, 14) + SourceIndex(0) -4 >Emitted(64, 12) Source(100, 2) + SourceIndex(0) +1->Emitted(63, 1) Source(76, 1) + SourceIndex(0) +2 >Emitted(63, 5) Source(76, 8) + SourceIndex(0) +3 >Emitted(63, 11) Source(76, 14) + SourceIndex(0) +4 >Emitted(63, 12) Source(100, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -1300,9 +1299,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 >module 3 > Sample -1->Emitted(65, 1) Source(76, 1) + SourceIndex(0) -2 >Emitted(65, 12) Source(76, 8) + SourceIndex(0) -3 >Emitted(65, 18) Source(76, 14) + SourceIndex(0) +1->Emitted(64, 1) Source(76, 1) + SourceIndex(0) +2 >Emitted(64, 12) Source(76, 8) + SourceIndex(0) +3 >Emitted(64, 18) Source(76, 14) + SourceIndex(0) --- >>> var Thing; 1 >^^^^ @@ -1338,10 +1337,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(66, 5) Source(76, 15) + SourceIndex(0) name (Sample) -2 >Emitted(66, 9) Source(76, 15) + SourceIndex(0) name (Sample) -3 >Emitted(66, 14) Source(76, 20) + SourceIndex(0) name (Sample) -4 >Emitted(66, 15) Source(100, 2) + SourceIndex(0) name (Sample) +1 >Emitted(65, 5) Source(76, 15) + SourceIndex(0) name (Sample) +2 >Emitted(65, 9) Source(76, 15) + SourceIndex(0) name (Sample) +3 >Emitted(65, 14) Source(76, 20) + SourceIndex(0) name (Sample) +4 >Emitted(65, 15) Source(100, 2) + SourceIndex(0) name (Sample) --- >>> (function (Thing) { 1->^^^^ @@ -1351,9 +1350,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(67, 5) Source(76, 15) + SourceIndex(0) name (Sample) -2 >Emitted(67, 16) Source(76, 15) + SourceIndex(0) name (Sample) -3 >Emitted(67, 21) Source(76, 20) + SourceIndex(0) name (Sample) +1->Emitted(66, 5) Source(76, 15) + SourceIndex(0) name (Sample) +2 >Emitted(66, 16) Source(76, 15) + SourceIndex(0) name (Sample) +3 >Emitted(66, 21) Source(76, 20) + SourceIndex(0) name (Sample) --- >>> var Languages; 1->^^^^^^^^ @@ -1389,10 +1388,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(68, 9) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -2 >Emitted(68, 13) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -3 >Emitted(68, 22) Source(76, 30) + SourceIndex(0) name (Sample.Thing) -4 >Emitted(68, 23) Source(100, 2) + SourceIndex(0) name (Sample.Thing) +1->Emitted(67, 9) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +2 >Emitted(67, 13) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +3 >Emitted(67, 22) Source(76, 30) + SourceIndex(0) name (Sample.Thing) +4 >Emitted(67, 23) Source(100, 2) + SourceIndex(0) name (Sample.Thing) --- >>> (function (Languages) { 1->^^^^^^^^ @@ -1401,9 +1400,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Languages -1->Emitted(69, 9) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -2 >Emitted(69, 20) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -3 >Emitted(69, 29) Source(76, 30) + SourceIndex(0) name (Sample.Thing) +1->Emitted(68, 9) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +2 >Emitted(68, 20) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +3 >Emitted(68, 29) Source(76, 30) + SourceIndex(0) name (Sample.Thing) --- >>> var PlainText; 1 >^^^^^^^^^^^^ @@ -1439,10 +1438,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(70, 13) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -2 >Emitted(70, 17) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -3 >Emitted(70, 26) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) -4 >Emitted(70, 27) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages) +1 >Emitted(69, 13) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +2 >Emitted(69, 17) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +3 >Emitted(69, 26) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) +4 >Emitted(69, 27) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages) --- >>> (function (PlainText) { 1->^^^^^^^^^^^^ @@ -1456,11 +1455,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > PlainText 4 > 5 > { -1->Emitted(71, 13) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -2 >Emitted(71, 24) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -3 >Emitted(71, 33) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) -4 >Emitted(71, 35) Source(76, 41) + SourceIndex(0) name (Sample.Thing.Languages) -5 >Emitted(71, 36) Source(76, 42) + SourceIndex(0) name (Sample.Thing.Languages) +1->Emitted(70, 13) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +2 >Emitted(70, 24) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +3 >Emitted(70, 33) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) +4 >Emitted(70, 35) Source(76, 41) + SourceIndex(0) name (Sample.Thing.Languages) +5 >Emitted(70, 36) Source(76, 42) + SourceIndex(0) name (Sample.Thing.Languages) --- >>> var State = (function () { 1->^^^^^^^^^^^^^^^^ @@ -1468,7 +1467,7 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > > -1->Emitted(72, 17) Source(78, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +1->Emitted(71, 17) Source(78, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) --- >>> function State(mode) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1479,9 +1478,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > constructor(private 3 > mode: IMode -1->Emitted(73, 21) Source(79, 9) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -2 >Emitted(73, 36) Source(79, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -3 >Emitted(73, 40) Source(79, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +1->Emitted(72, 21) Source(79, 9) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +2 >Emitted(72, 36) Source(79, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +3 >Emitted(72, 40) Source(79, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) --- >>> this.mode = mode; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1494,11 +1493,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > mode 5 > : IMode -1->Emitted(74, 25) Source(79, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) -2 >Emitted(74, 34) Source(79, 33) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) -3 >Emitted(74, 37) Source(79, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) -4 >Emitted(74, 41) Source(79, 33) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) -5 >Emitted(74, 42) Source(79, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +1->Emitted(73, 25) Source(79, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +2 >Emitted(73, 34) Source(79, 33) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +3 >Emitted(73, 37) Source(79, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +4 >Emitted(73, 41) Source(79, 33) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +5 >Emitted(73, 42) Source(79, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1506,8 +1505,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >) { 2 > } -1 >Emitted(75, 21) Source(79, 44) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) -2 >Emitted(75, 22) Source(79, 45) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +1 >Emitted(74, 21) Source(79, 44) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) +2 >Emitted(74, 22) Source(79, 45) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.constructor) --- >>> State.prototype.clone = function () { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1517,9 +1516,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > clone 3 > -1->Emitted(76, 21) Source(80, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -2 >Emitted(76, 42) Source(80, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -3 >Emitted(76, 45) Source(80, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +1->Emitted(75, 21) Source(80, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +2 >Emitted(75, 42) Source(80, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +3 >Emitted(75, 45) Source(80, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) --- >>> return this; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1533,11 +1532,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > this 5 > ; -1 >Emitted(77, 25) Source(81, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) -2 >Emitted(77, 31) Source(81, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) -3 >Emitted(77, 32) Source(81, 11) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) -4 >Emitted(77, 36) Source(81, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) -5 >Emitted(77, 37) Source(81, 16) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +1 >Emitted(76, 25) Source(81, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +2 >Emitted(76, 31) Source(81, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +3 >Emitted(76, 32) Source(81, 11) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +4 >Emitted(76, 36) Source(81, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +5 >Emitted(76, 37) Source(81, 16) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1546,8 +1545,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(78, 21) Source(82, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) -2 >Emitted(78, 22) Source(82, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +1 >Emitted(77, 21) Source(82, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) +2 >Emitted(77, 22) Source(82, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.clone) --- >>> State.prototype.equals = function (other) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1562,11 +1561,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > public equals( 5 > other:IState -1->Emitted(79, 21) Source(84, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -2 >Emitted(79, 43) Source(84, 16) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -3 >Emitted(79, 46) Source(84, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -4 >Emitted(79, 56) Source(84, 17) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -5 >Emitted(79, 61) Source(84, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +1->Emitted(78, 21) Source(84, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +2 >Emitted(78, 43) Source(84, 16) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +3 >Emitted(78, 46) Source(84, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +4 >Emitted(78, 56) Source(84, 17) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +5 >Emitted(78, 61) Source(84, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) --- >>> return this === other; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1584,13 +1583,13 @@ sourceFile:recursiveClassReferenceTest.ts 5 > === 6 > other 7 > ; -1 >Emitted(80, 25) Source(85, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -2 >Emitted(80, 31) Source(85, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -3 >Emitted(80, 32) Source(85, 11) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -4 >Emitted(80, 36) Source(85, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -5 >Emitted(80, 41) Source(85, 20) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -6 >Emitted(80, 46) Source(85, 25) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -7 >Emitted(80, 47) Source(85, 26) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +1 >Emitted(79, 25) Source(85, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +2 >Emitted(79, 31) Source(85, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +3 >Emitted(79, 32) Source(85, 11) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +4 >Emitted(79, 36) Source(85, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +5 >Emitted(79, 41) Source(85, 20) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +6 >Emitted(79, 46) Source(85, 25) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +7 >Emitted(79, 47) Source(85, 26) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1599,8 +1598,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(81, 21) Source(86, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) -2 >Emitted(81, 22) Source(86, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +1 >Emitted(80, 21) Source(86, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) +2 >Emitted(80, 22) Source(86, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.equals) --- >>> State.prototype.getMode = function () { return mode; }; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1625,16 +1624,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(82, 21) Source(88, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -2 >Emitted(82, 44) Source(88, 17) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -3 >Emitted(82, 47) Source(88, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -4 >Emitted(82, 61) Source(88, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) -5 >Emitted(82, 67) Source(88, 35) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) -6 >Emitted(82, 68) Source(88, 36) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) -7 >Emitted(82, 72) Source(88, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) -8 >Emitted(82, 73) Source(88, 41) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) -9 >Emitted(82, 74) Source(88, 42) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) -10>Emitted(82, 75) Source(88, 43) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +1->Emitted(81, 21) Source(88, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +2 >Emitted(81, 44) Source(88, 17) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +3 >Emitted(81, 47) Source(88, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +4 >Emitted(81, 61) Source(88, 29) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +5 >Emitted(81, 67) Source(88, 35) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +6 >Emitted(81, 68) Source(88, 36) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +7 >Emitted(81, 72) Source(88, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +8 >Emitted(81, 73) Source(88, 41) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +9 >Emitted(81, 74) Source(88, 42) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) +10>Emitted(81, 75) Source(88, 43) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State.getMode) --- >>> return State; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1642,8 +1641,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(83, 21) Source(89, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -2 >Emitted(83, 33) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +1 >Emitted(82, 21) Source(89, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +2 >Emitted(82, 33) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) --- >>> })(); 1 >^^^^^^^^^^^^^^^^ @@ -1666,10 +1665,10 @@ sourceFile:recursiveClassReferenceTest.ts > > public getMode(): IMode { return mode; } > } -1 >Emitted(84, 17) Source(89, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -2 >Emitted(84, 18) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) -3 >Emitted(84, 18) Source(78, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -4 >Emitted(84, 22) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +1 >Emitted(83, 17) Source(89, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +2 >Emitted(83, 18) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.State) +3 >Emitted(83, 18) Source(78, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +4 >Emitted(83, 22) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) --- >>> PlainText.State = State; 1->^^^^^^^^^^^^^^^^ @@ -1692,10 +1691,10 @@ sourceFile:recursiveClassReferenceTest.ts > public getMode(): IMode { return mode; } > } 4 > -1->Emitted(85, 17) Source(78, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -2 >Emitted(85, 32) Source(78, 20) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -3 >Emitted(85, 40) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -4 >Emitted(85, 41) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +1->Emitted(84, 17) Source(78, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +2 >Emitted(84, 32) Source(78, 20) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +3 >Emitted(84, 40) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +4 >Emitted(84, 41) Source(89, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) --- >>> var Mode = (function (_super) { 1->^^^^^^^^^^^^^^^^ @@ -1703,29 +1702,29 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > > -1->Emitted(86, 17) Source(91, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +1->Emitted(85, 17) Source(91, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) --- >>> __extends(Mode, _super); 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^ 1->export class Mode extends 2 > AbstractMode -1->Emitted(87, 21) Source(91, 28) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -2 >Emitted(87, 45) Source(91, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +1->Emitted(86, 21) Source(91, 28) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +2 >Emitted(86, 45) Source(91, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) --- >>> function Mode() { 1 >^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(88, 21) Source(91, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +1 >Emitted(87, 21) Source(91, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) --- >>> _super.apply(this, arguments); 1->^^^^^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->export class Mode extends 2 > AbstractMode -1->Emitted(89, 25) Source(91, 28) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) -2 >Emitted(89, 55) Source(91, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) +1->Emitted(88, 25) Source(91, 28) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) +2 >Emitted(88, 55) Source(91, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1741,8 +1740,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1 >Emitted(90, 21) Source(99, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) -2 >Emitted(90, 22) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) +1 >Emitted(89, 21) Source(99, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) +2 >Emitted(89, 22) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.constructor) --- >>> // scenario 2 1->^^^^^^^^^^^^^^^^^^^^ @@ -1750,8 +1749,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> 2 > // scenario 2 -1->Emitted(91, 21) Source(93, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -2 >Emitted(91, 34) Source(93, 16) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +1->Emitted(90, 21) Source(93, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +2 >Emitted(90, 34) Source(93, 16) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) --- >>> Mode.prototype.getInitialState = function () { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1761,9 +1760,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getInitialState 3 > -1->Emitted(92, 21) Source(94, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -2 >Emitted(92, 51) Source(94, 25) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -3 >Emitted(92, 54) Source(94, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +1->Emitted(91, 21) Source(94, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +2 >Emitted(91, 51) Source(94, 25) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +3 >Emitted(91, 54) Source(94, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) --- >>> return new State(self); 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1785,15 +1784,15 @@ sourceFile:recursiveClassReferenceTest.ts 7 > self 8 > ) 9 > ; -1 >Emitted(93, 25) Source(95, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -2 >Emitted(93, 31) Source(95, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -3 >Emitted(93, 32) Source(95, 11) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -4 >Emitted(93, 36) Source(95, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -5 >Emitted(93, 41) Source(95, 20) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -6 >Emitted(93, 42) Source(95, 21) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -7 >Emitted(93, 46) Source(95, 25) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -8 >Emitted(93, 47) Source(95, 26) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -9 >Emitted(93, 48) Source(95, 27) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +1 >Emitted(92, 25) Source(95, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +2 >Emitted(92, 31) Source(95, 10) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +3 >Emitted(92, 32) Source(95, 11) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +4 >Emitted(92, 36) Source(95, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +5 >Emitted(92, 41) Source(95, 20) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +6 >Emitted(92, 42) Source(95, 21) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +7 >Emitted(92, 46) Source(95, 25) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +8 >Emitted(92, 47) Source(95, 26) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +9 >Emitted(92, 48) Source(95, 27) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1802,8 +1801,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(94, 21) Source(96, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) -2 >Emitted(94, 22) Source(96, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +1 >Emitted(93, 21) Source(96, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) +2 >Emitted(93, 22) Source(96, 4) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode.getInitialState) --- >>> return Mode; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1814,8 +1813,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(95, 21) Source(99, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -2 >Emitted(95, 32) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +1->Emitted(94, 21) Source(99, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +2 >Emitted(94, 32) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) --- >>> })(AbstractMode); 1->^^^^^^^^^^^^^^^^ @@ -1839,12 +1838,12 @@ sourceFile:recursiveClassReferenceTest.ts > > > } -1->Emitted(96, 17) Source(99, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -2 >Emitted(96, 18) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) -3 >Emitted(96, 18) Source(91, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -4 >Emitted(96, 20) Source(91, 28) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -5 >Emitted(96, 32) Source(91, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -6 >Emitted(96, 34) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +1->Emitted(95, 17) Source(99, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +2 >Emitted(95, 18) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText.Mode) +3 >Emitted(95, 18) Source(91, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +4 >Emitted(95, 20) Source(91, 28) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +5 >Emitted(95, 32) Source(91, 40) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +6 >Emitted(95, 34) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) --- >>> PlainText.Mode = Mode; 1->^^^^^^^^^^^^^^^^ @@ -1864,10 +1863,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } 4 > -1->Emitted(97, 17) Source(91, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -2 >Emitted(97, 31) Source(91, 19) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -3 >Emitted(97, 38) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -4 >Emitted(97, 39) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +1->Emitted(96, 17) Source(91, 15) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +2 >Emitted(96, 31) Source(91, 19) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +3 >Emitted(96, 38) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +4 >Emitted(96, 39) Source(99, 3) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) --- >>> })(PlainText = Languages.PlainText || (Languages.PlainText = {})); 1->^^^^^^^^^^^^ @@ -1913,15 +1912,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(98, 13) Source(100, 1) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -2 >Emitted(98, 14) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) -3 >Emitted(98, 16) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -4 >Emitted(98, 25) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) -5 >Emitted(98, 28) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -6 >Emitted(98, 47) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) -7 >Emitted(98, 52) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) -8 >Emitted(98, 71) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) -9 >Emitted(98, 79) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages) +1->Emitted(97, 13) Source(100, 1) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +2 >Emitted(97, 14) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages.PlainText) +3 >Emitted(97, 16) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +4 >Emitted(97, 25) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) +5 >Emitted(97, 28) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +6 >Emitted(97, 47) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) +7 >Emitted(97, 52) Source(76, 31) + SourceIndex(0) name (Sample.Thing.Languages) +8 >Emitted(97, 71) Source(76, 40) + SourceIndex(0) name (Sample.Thing.Languages) +9 >Emitted(97, 79) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages) --- >>> })(Languages = Thing.Languages || (Thing.Languages = {})); 1 >^^^^^^^^ @@ -1966,15 +1965,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(99, 9) Source(100, 1) + SourceIndex(0) name (Sample.Thing.Languages) -2 >Emitted(99, 10) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages) -3 >Emitted(99, 12) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -4 >Emitted(99, 21) Source(76, 30) + SourceIndex(0) name (Sample.Thing) -5 >Emitted(99, 24) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -6 >Emitted(99, 39) Source(76, 30) + SourceIndex(0) name (Sample.Thing) -7 >Emitted(99, 44) Source(76, 21) + SourceIndex(0) name (Sample.Thing) -8 >Emitted(99, 59) Source(76, 30) + SourceIndex(0) name (Sample.Thing) -9 >Emitted(99, 67) Source(100, 2) + SourceIndex(0) name (Sample.Thing) +1 >Emitted(98, 9) Source(100, 1) + SourceIndex(0) name (Sample.Thing.Languages) +2 >Emitted(98, 10) Source(100, 2) + SourceIndex(0) name (Sample.Thing.Languages) +3 >Emitted(98, 12) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +4 >Emitted(98, 21) Source(76, 30) + SourceIndex(0) name (Sample.Thing) +5 >Emitted(98, 24) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +6 >Emitted(98, 39) Source(76, 30) + SourceIndex(0) name (Sample.Thing) +7 >Emitted(98, 44) Source(76, 21) + SourceIndex(0) name (Sample.Thing) +8 >Emitted(98, 59) Source(76, 30) + SourceIndex(0) name (Sample.Thing) +9 >Emitted(98, 67) Source(100, 2) + SourceIndex(0) name (Sample.Thing) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -2019,15 +2018,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(100, 5) Source(100, 1) + SourceIndex(0) name (Sample.Thing) -2 >Emitted(100, 6) Source(100, 2) + SourceIndex(0) name (Sample.Thing) -3 >Emitted(100, 8) Source(76, 15) + SourceIndex(0) name (Sample) -4 >Emitted(100, 13) Source(76, 20) + SourceIndex(0) name (Sample) -5 >Emitted(100, 16) Source(76, 15) + SourceIndex(0) name (Sample) -6 >Emitted(100, 28) Source(76, 20) + SourceIndex(0) name (Sample) -7 >Emitted(100, 33) Source(76, 15) + SourceIndex(0) name (Sample) -8 >Emitted(100, 45) Source(76, 20) + SourceIndex(0) name (Sample) -9 >Emitted(100, 53) Source(100, 2) + SourceIndex(0) name (Sample) +1 >Emitted(99, 5) Source(100, 1) + SourceIndex(0) name (Sample.Thing) +2 >Emitted(99, 6) Source(100, 2) + SourceIndex(0) name (Sample.Thing) +3 >Emitted(99, 8) Source(76, 15) + SourceIndex(0) name (Sample) +4 >Emitted(99, 13) Source(76, 20) + SourceIndex(0) name (Sample) +5 >Emitted(99, 16) Source(76, 15) + SourceIndex(0) name (Sample) +6 >Emitted(99, 28) Source(76, 20) + SourceIndex(0) name (Sample) +7 >Emitted(99, 33) Source(76, 15) + SourceIndex(0) name (Sample) +8 >Emitted(99, 45) Source(76, 20) + SourceIndex(0) name (Sample) +9 >Emitted(99, 53) Source(100, 2) + SourceIndex(0) name (Sample) --- >>>})(Sample || (Sample = {})); 1 > @@ -2069,12 +2068,12 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(101, 1) Source(100, 1) + SourceIndex(0) name (Sample) -2 >Emitted(101, 2) Source(100, 2) + SourceIndex(0) name (Sample) -3 >Emitted(101, 4) Source(76, 8) + SourceIndex(0) -4 >Emitted(101, 10) Source(76, 14) + SourceIndex(0) -5 >Emitted(101, 15) Source(76, 8) + SourceIndex(0) -6 >Emitted(101, 21) Source(76, 14) + SourceIndex(0) -7 >Emitted(101, 29) Source(100, 2) + SourceIndex(0) +1 >Emitted(100, 1) Source(100, 1) + SourceIndex(0) name (Sample) +2 >Emitted(100, 2) Source(100, 2) + SourceIndex(0) name (Sample) +3 >Emitted(100, 4) Source(76, 8) + SourceIndex(0) +4 >Emitted(100, 10) Source(76, 14) + SourceIndex(0) +5 >Emitted(100, 15) Source(76, 8) + SourceIndex(0) +6 >Emitted(100, 21) Source(76, 14) + SourceIndex(0) +7 >Emitted(100, 29) Source(100, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=recursiveClassReferenceTest.js.map \ No newline at end of file diff --git a/tests/baselines/reference/recursiveComplicatedClasses.js b/tests/baselines/reference/recursiveComplicatedClasses.js index 6e88dd8dc22..e35931008b2 100644 --- a/tests/baselines/reference/recursiveComplicatedClasses.js +++ b/tests/baselines/reference/recursiveComplicatedClasses.js @@ -28,8 +28,7 @@ class TypeSymbol extends InferenceSymbol { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Signature = (function () { function Signature() { diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index 60022dc245a..48e8b1c4eba 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -33,8 +33,7 @@ declare module MsPortal.Controls.Base.ItemList { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var MsPortal; (function (MsPortal) { diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types index bccd226ceba..af9e13d4002 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types @@ -29,7 +29,7 @@ module MsPortal.Controls.Base.ItemList { export class ViewModel extends ItemValue { >ViewModel : ViewModel >TValue : TValue ->ItemValue : ItemValue +>ItemValue : ItemValue >TValue : TValue } } diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js index 72cc702309c..3ba03a1e03c 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js @@ -1023,8 +1023,7 @@ module caurinus { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var rionegrensis; (function (rionegrensis) { diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types index 43db869265b..c9025b56502 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types @@ -4,9 +4,9 @@ module rionegrensis { export class caniventer extends Lanthanum.nitidus { >caniventer : caniventer ->Lanthanum.nitidus : any +>Lanthanum.nitidus : Lanthanum.nitidus >Lanthanum : typeof Lanthanum ->nitidus : Lanthanum.nitidus +>nitidus : typeof Lanthanum.nitidus >petrophilus : any >minutilla : petrophilus.minutilla >julianae : any @@ -90,9 +90,9 @@ module rionegrensis { >veraecrucis : veraecrucis >T0 : T0 >T1 : T1 ->trivirgatus.mixtus : any +>trivirgatus.mixtus : trivirgatus.mixtus >trivirgatus : typeof trivirgatus ->mixtus : trivirgatus.mixtus +>mixtus : typeof trivirgatus.mixtus >gabriellae : any >amicus : gabriellae.amicus >lutreolus : any @@ -516,9 +516,9 @@ module julianae { >oralis : oralis >T0 : T0 >T1 : T1 ->caurinus.psilurus : any +>caurinus.psilurus : caurinus.psilurus >caurinus : typeof caurinus ->psilurus : caurinus.psilurus +>psilurus : typeof caurinus.psilurus cepapi() : caurinus.psilurus { var x : caurinus.psilurus; () => { var y = this; }; return x; } >cepapi : () => caurinus.psilurus @@ -754,9 +754,9 @@ module julianae { } export class sumatrana extends Lanthanum.jugularis { >sumatrana : sumatrana ->Lanthanum.jugularis : any +>Lanthanum.jugularis : Lanthanum.jugularis >Lanthanum : typeof Lanthanum ->jugularis : Lanthanum.jugularis +>jugularis : typeof Lanthanum.jugularis wolffsohni() : Lanthanum.suillus { var x : Lanthanum.suillus; () => { var y = this; }; return x; } >wolffsohni : () => Lanthanum.suillus @@ -1280,9 +1280,9 @@ module julianae { } export class durangae extends dogramacii.aurata { >durangae : durangae ->dogramacii.aurata : any +>dogramacii.aurata : dogramacii.aurata >dogramacii : typeof dogramacii ->aurata : dogramacii.aurata +>aurata : typeof dogramacii.aurata Californium() : panamensis.setulosus { var x : panamensis.setulosus; () => { var y = this; }; return x; } >Californium : () => panamensis.setulosus @@ -1434,9 +1434,9 @@ module Lanthanum { >nitidus : nitidus >T0 : T0 >T1 : T1 ->argurus.gilbertii : any +>argurus.gilbertii : argurus.gilbertii >argurus : typeof argurus ->gilbertii : argurus.gilbertii +>gilbertii : typeof argurus.gilbertii >lavali : any >thaeleri : lavali.thaeleri >lutreolus : any @@ -1604,9 +1604,9 @@ module Lanthanum { } export class megalonyx extends caurinus.johorensis { >megalonyx : megalonyx ->caurinus.johorensis : any +>caurinus.johorensis : caurinus.johorensis >caurinus : typeof caurinus ->johorensis : caurinus.johorensis +>johorensis : typeof caurinus.johorensis >caurinus : any >megaphyllus : caurinus.megaphyllus >julianae : any @@ -1991,9 +1991,9 @@ module rendalli { export class zuluensis extends julianae.steerii { >zuluensis : zuluensis ->julianae.steerii : any +>julianae.steerii : julianae.steerii >julianae : typeof julianae ->steerii : julianae.steerii +>steerii : typeof julianae.steerii telfairi() : argurus.wetmorei { var x : argurus.wetmorei; () => { var y = this; }; return x; } >telfairi : () => argurus.wetmorei @@ -2426,9 +2426,9 @@ module rendalli { >crenulata : crenulata >T0 : T0 >T1 : T1 ->trivirgatus.falconeri : any +>trivirgatus.falconeri : trivirgatus.falconeri >trivirgatus : typeof trivirgatus ->falconeri : trivirgatus.falconeri +>falconeri : typeof trivirgatus.falconeri salvanius() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } >salvanius : () => howi.coludo @@ -2621,9 +2621,9 @@ module trivirgatus { >mixtus : mixtus >T0 : T0 >T1 : T1 ->argurus.pygmaea : any +>argurus.pygmaea : argurus.pygmaea> >argurus : typeof argurus ->pygmaea : argurus.pygmaea +>pygmaea : typeof argurus.pygmaea >argurus : any >oreas : argurus.oreas >panglima : any @@ -3359,9 +3359,9 @@ module ruatanica { export class americanus extends imperfecta.ciliolabrum { >americanus : americanus ->imperfecta.ciliolabrum : any +>imperfecta.ciliolabrum : imperfecta.ciliolabrum >imperfecta : typeof imperfecta ->ciliolabrum : imperfecta.ciliolabrum +>ciliolabrum : typeof imperfecta.ciliolabrum >argurus : any >germaini : argurus.germaini >lutreolus : any @@ -3429,9 +3429,9 @@ module lavali { export class wilsoni extends Lanthanum.nitidus { >wilsoni : wilsoni ->Lanthanum.nitidus : any +>Lanthanum.nitidus : Lanthanum.nitidus >Lanthanum : typeof Lanthanum ->nitidus : Lanthanum.nitidus +>nitidus : typeof Lanthanum.nitidus >rionegrensis : any >caniventer : rionegrensis.caniventer >Lanthanum : any @@ -3650,9 +3650,9 @@ module lavali { } export class otion extends howi.coludo { >otion : otion ->howi.coludo : any +>howi.coludo : howi.coludo >howi : typeof howi ->coludo : howi.coludo +>coludo : typeof howi.coludo >argurus : any >oreas : argurus.oreas >howi : any @@ -4125,9 +4125,9 @@ module lavali { } export class thaeleri extends argurus.oreas { >thaeleri : thaeleri ->argurus.oreas : any +>argurus.oreas : argurus.oreas >argurus : typeof argurus ->oreas : argurus.oreas +>oreas : typeof argurus.oreas coromandra() : julianae.galapagoensis { var x : julianae.galapagoensis; () => { var y = this; }; return x; } >coromandra : () => julianae.galapagoensis @@ -4289,9 +4289,9 @@ module lavali { } export class lepturus extends Lanthanum.suillus { >lepturus : lepturus ->Lanthanum.suillus : any +>Lanthanum.suillus : Lanthanum.suillus >Lanthanum : typeof Lanthanum ->suillus : Lanthanum.suillus +>suillus : typeof Lanthanum.suillus >dammermani : any >melanops : dammermani.melanops >quasiater : any @@ -4365,9 +4365,9 @@ module dogramacii { export class robustulus extends lavali.wilsoni { >robustulus : robustulus ->lavali.wilsoni : any +>lavali.wilsoni : lavali.wilsoni >lavali : typeof lavali ->wilsoni : lavali.wilsoni +>wilsoni : typeof lavali.wilsoni fossor() : minutus.inez { var x : minutus.inez; () => { var y = this; }; return x; } >fossor : () => minutus.inez @@ -4940,9 +4940,9 @@ module lutreolus { export class schlegeli extends lavali.beisa { >schlegeli : schlegeli ->lavali.beisa : any +>lavali.beisa : lavali.beisa >lavali : typeof lavali ->beisa : lavali.beisa +>beisa : typeof lavali.beisa mittendorfi() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } >mittendorfi : () => rionegrensis.caniventer @@ -5678,9 +5678,9 @@ module panglima { >amphibius : amphibius >T0 : T0 >T1 : T1 ->caurinus.johorensis : any +>caurinus.johorensis : caurinus.johorensis, Lanthanum.jugularis> >caurinus : typeof caurinus ->johorensis : caurinus.johorensis +>johorensis : typeof caurinus.johorensis >Lanthanum : any >nitidus : Lanthanum.nitidus >petrophilus : any @@ -5812,9 +5812,9 @@ module panglima { >fundatus : fundatus >T0 : T0 >T1 : T1 ->lutreolus.schlegeli : any +>lutreolus.schlegeli : lutreolus.schlegeli >lutreolus : typeof lutreolus ->schlegeli : lutreolus.schlegeli +>schlegeli : typeof lutreolus.schlegeli crassulus(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } >crassulus : () => nigra.gracilis @@ -5918,9 +5918,9 @@ module panglima { >abidi : abidi >T0 : T0 >T1 : T1 ->argurus.dauricus : any +>argurus.dauricus : argurus.dauricus >argurus : typeof argurus ->dauricus : argurus.dauricus +>dauricus : typeof argurus.dauricus >argurus : any >germaini : argurus.germaini >julianae : any @@ -6133,9 +6133,9 @@ module minutus { >himalayana : himalayana >T0 : T0 >T1 : T1 ->lutreolus.punicus : any +>lutreolus.punicus : lutreolus.punicus >lutreolus : typeof lutreolus ->punicus : lutreolus.punicus +>punicus : typeof lutreolus.punicus simoni(): argurus.netscheri> { var x: argurus.netscheri>; () => { var y = this; }; return x; } >simoni : () => argurus.netscheri> @@ -6377,9 +6377,9 @@ module caurinus { >mahaganus : mahaganus >T0 : T0 >T1 : T1 ->panglima.fundatus : any +>panglima.fundatus : panglima.fundatus >panglima : typeof panglima ->fundatus : panglima.fundatus +>fundatus : typeof panglima.fundatus >quasiater : any >carolinensis : quasiater.carolinensis >macrorhinos : any @@ -6606,9 +6606,9 @@ module howi { >angulatus : angulatus >T0 : T0 >T1 : T1 ->sagitta.stolzmanni : any +>sagitta.stolzmanni : sagitta.stolzmanni >sagitta : typeof sagitta ->stolzmanni : sagitta.stolzmanni +>stolzmanni : typeof sagitta.stolzmanni pennatus(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } >pennatus : () => marcanoi @@ -6814,9 +6814,9 @@ module sagitta { export class walkeri extends minutus.portoricensis { >walkeri : walkeri ->minutus.portoricensis : any +>minutus.portoricensis : minutus.portoricensis >minutus : typeof minutus ->portoricensis : minutus.portoricensis +>portoricensis : typeof minutus.portoricensis maracajuensis(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } >maracajuensis : () => samarensis.cahirinus @@ -6846,9 +6846,9 @@ module minutus { >inez : inez >T0 : T0 >T1 : T1 ->samarensis.pelurus : any +>samarensis.pelurus : samarensis.pelurus >samarensis : typeof samarensis ->pelurus : samarensis.pelurus +>pelurus : typeof samarensis.pelurus >argurus : any >germaini : argurus.germaini >julianae : any @@ -6880,9 +6880,9 @@ module macrorhinos { export class konganensis extends imperfecta.lasiurus { >konganensis : konganensis ->imperfecta.lasiurus : any +>imperfecta.lasiurus : imperfecta.lasiurus >imperfecta : typeof imperfecta ->lasiurus : imperfecta.lasiurus +>lasiurus : typeof imperfecta.lasiurus >caurinus : any >psilurus : caurinus.psilurus >caurinus : any @@ -6896,9 +6896,9 @@ module panamensis { >linulus : linulus >T0 : T0 >T1 : T1 ->ruatanica.hector : any +>ruatanica.hector : ruatanica.hector> >ruatanica : typeof ruatanica ->hector : ruatanica.hector +>hector : typeof ruatanica.hector >julianae : any >sumatrana : julianae.sumatrana >samarensis : any @@ -7357,9 +7357,9 @@ module samarensis { >pelurus : pelurus >T0 : T0 >T1 : T1 ->sagitta.stolzmanni : any +>sagitta.stolzmanni : sagitta.stolzmanni >sagitta : typeof sagitta ->stolzmanni : sagitta.stolzmanni +>stolzmanni : typeof sagitta.stolzmanni Palladium(): panamensis.linulus { var x: panamensis.linulus; () => { var y = this; }; return x; } >Palladium : () => panamensis.linulus @@ -7615,9 +7615,9 @@ module samarensis { >fuscus : fuscus >T0 : T0 >T1 : T1 ->macrorhinos.daphaenodon : any +>macrorhinos.daphaenodon : macrorhinos.daphaenodon >macrorhinos : typeof macrorhinos ->daphaenodon : macrorhinos.daphaenodon +>daphaenodon : typeof macrorhinos.daphaenodon planifrons(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } >planifrons : () => nigra.gracilis @@ -8093,9 +8093,9 @@ module sagitta { >leptoceros : leptoceros >T0 : T0 >T1 : T1 ->caurinus.johorensis : any +>caurinus.johorensis : caurinus.johorensis> >caurinus : typeof caurinus ->johorensis : caurinus.johorensis +>johorensis : typeof caurinus.johorensis >argurus : any >peninsulae : argurus.peninsulae >daubentonii : any @@ -8205,9 +8205,9 @@ module daubentonii { >nigricans : nigricans >T0 : T0 >T1 : T1 ->sagitta.stolzmanni : any +>sagitta.stolzmanni : sagitta.stolzmanni >sagitta : typeof sagitta ->stolzmanni : sagitta.stolzmanni +>stolzmanni : typeof sagitta.stolzmanni woosnami(): dogramacii.robustulus { var x: dogramacii.robustulus; () => { var y = this; }; return x; } >woosnami : () => dogramacii.robustulus @@ -8238,9 +8238,9 @@ module argurus { >pygmaea : pygmaea >T0 : T0 >T1 : T1 ->rendalli.moojeni : any +>rendalli.moojeni : rendalli.moojeni >rendalli : typeof rendalli ->moojeni : rendalli.moojeni +>moojeni : typeof rendalli.moojeni >macrorhinos : any >konganensis : macrorhinos.konganensis >gabriellae : any @@ -8290,9 +8290,9 @@ module chrysaeolus { >sarasinorum : sarasinorum >T0 : T0 >T1 : T1 ->caurinus.psilurus : any +>caurinus.psilurus : caurinus.psilurus >caurinus : typeof caurinus ->psilurus : caurinus.psilurus +>psilurus : typeof caurinus.psilurus belzebul(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } >belzebul : () => samarensis.pallidus @@ -8533,9 +8533,9 @@ module argurus { export class oreas extends lavali.wilsoni { >oreas : oreas ->lavali.wilsoni : any +>lavali.wilsoni : lavali.wilsoni >lavali : typeof lavali ->wilsoni : lavali.wilsoni +>wilsoni : typeof lavali.wilsoni salamonis(): lavali.xanthognathus { var x: lavali.xanthognathus; () => { var y = this; }; return x; } >salamonis : () => lavali.xanthognathus @@ -9163,9 +9163,9 @@ module provocax { export class melanoleuca extends lavali.wilsoni { >melanoleuca : melanoleuca ->lavali.wilsoni : any +>lavali.wilsoni : lavali.wilsoni >lavali : typeof lavali ->wilsoni : lavali.wilsoni +>wilsoni : typeof lavali.wilsoni Neodymium(): macrorhinos.marmosurus, lutreolus.foina> { var x: macrorhinos.marmosurus, lutreolus.foina>; () => { var y = this; }; return x; } >Neodymium : () => macrorhinos.marmosurus, lutreolus.foina> @@ -9310,9 +9310,9 @@ module howi { export class marcanoi extends Lanthanum.megalonyx { >marcanoi : marcanoi ->Lanthanum.megalonyx : any +>Lanthanum.megalonyx : Lanthanum.megalonyx >Lanthanum : typeof Lanthanum ->megalonyx : Lanthanum.megalonyx +>megalonyx : typeof Lanthanum.megalonyx formosae(): Lanthanum.megalonyx { var x: Lanthanum.megalonyx; () => { var y = this; }; return x; } >formosae : () => Lanthanum.megalonyx @@ -10398,9 +10398,9 @@ module gabriellae { >klossii : klossii >T0 : T0 >T1 : T1 ->imperfecta.lasiurus : any +>imperfecta.lasiurus : imperfecta.lasiurus >imperfecta : typeof imperfecta ->lasiurus : imperfecta.lasiurus +>lasiurus : typeof imperfecta.lasiurus >dogramacii : any >robustulus : dogramacii.robustulus >caurinus : any @@ -10908,9 +10908,9 @@ module imperfecta { >ciliolabrum : ciliolabrum >T0 : T0 >T1 : T1 ->dogramacii.robustulus : any +>dogramacii.robustulus : dogramacii.robustulus >dogramacii : typeof dogramacii ->robustulus : dogramacii.robustulus +>robustulus : typeof dogramacii.robustulus leschenaultii(): argurus.dauricus> { var x: argurus.dauricus>; () => { var y = this; }; return x; } >leschenaultii : () => argurus.dauricus> @@ -11072,9 +11072,9 @@ module petrophilus { >sodyi : sodyi >T0 : T0 >T1 : T1 ->quasiater.bobrinskoi : any +>quasiater.bobrinskoi : quasiater.bobrinskoi >quasiater : typeof quasiater ->bobrinskoi : quasiater.bobrinskoi +>bobrinskoi : typeof quasiater.bobrinskoi saundersiae(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } >saundersiae : () => samarensis.pallidus @@ -11206,9 +11206,9 @@ module caurinus { export class megaphyllus extends imperfecta.lasiurus> { >megaphyllus : megaphyllus ->imperfecta.lasiurus : any +>imperfecta.lasiurus : imperfecta.lasiurus> >imperfecta : typeof imperfecta ->lasiurus : imperfecta.lasiurus +>lasiurus : typeof imperfecta.lasiurus >julianae : any >acariensis : julianae.acariensis >howi : any @@ -11640,9 +11640,9 @@ module lutreolus { >cor : cor >T0 : T0 >T1 : T1 ->panglima.fundatus : any +>panglima.fundatus : panglima.fundatus, lavali.beisa>, dammermani.melanops> >panglima : typeof panglima ->fundatus : panglima.fundatus +>fundatus : typeof panglima.fundatus >panamensis : any >linulus : panamensis.linulus >trivirgatus : any @@ -11887,9 +11887,9 @@ module argurus { export class germaini extends gabriellae.amicus { >germaini : germaini ->gabriellae.amicus : any +>gabriellae.amicus : gabriellae.amicus >gabriellae : typeof gabriellae ->amicus : gabriellae.amicus +>amicus : typeof gabriellae.amicus sharpei(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } >sharpei : () => lavali.wilsoni @@ -12100,9 +12100,9 @@ module dammermani { export class melanops extends minutus.inez { >melanops : melanops ->minutus.inez : any +>minutus.inez : minutus.inez >minutus : typeof minutus ->inez : minutus.inez +>inez : typeof minutus.inez >sagitta : any >stolzmanni : sagitta.stolzmanni >dammermani : any @@ -12350,9 +12350,9 @@ module argurus { export class peninsulae extends patas.uralensis { >peninsulae : peninsulae ->patas.uralensis : any +>patas.uralensis : patas.uralensis >patas : typeof patas ->uralensis : patas.uralensis +>uralensis : typeof patas.uralensis aitkeni(): trivirgatus.mixtus, panglima.amphibius> { var x: trivirgatus.mixtus, panglima.amphibius>; () => { var y = this; }; return x; } >aitkeni : () => trivirgatus.mixtus, panglima.amphibius> @@ -12815,9 +12815,9 @@ module ruatanica { >Praseodymium : Praseodymium >T0 : T0 >T1 : T1 ->ruatanica.hector : any +>ruatanica.hector : hector >ruatanica : typeof ruatanica ->hector : hector +>hector : typeof hector >lutreolus : any >punicus : lutreolus.punicus >gabriellae : any @@ -13163,9 +13163,9 @@ module caurinus { >johorensis : johorensis >T0 : T0 >T1 : T1 ->lutreolus.punicus : any +>lutreolus.punicus : lutreolus.punicus >lutreolus : typeof lutreolus ->punicus : lutreolus.punicus +>punicus : typeof lutreolus.punicus maini(): ruatanica.Praseodymium { var x: ruatanica.Praseodymium; () => { var y = this; }; return x; } >maini : () => ruatanica.Praseodymium @@ -13610,9 +13610,9 @@ module caurinus { export class psilurus extends lutreolus.punicus { >psilurus : psilurus ->lutreolus.punicus : any +>lutreolus.punicus : lutreolus.punicus >lutreolus : typeof lutreolus ->punicus : lutreolus.punicus +>punicus : typeof lutreolus.punicus socialis(): panglima.amphibius { var x: panglima.amphibius; () => { var y = this; }; return x; } >socialis : () => panglima.amphibius diff --git a/tests/baselines/reference/returnInConstructor1.js b/tests/baselines/reference/returnInConstructor1.js index 87b1b6d672a..e8781f06d24 100644 --- a/tests/baselines/reference/returnInConstructor1.js +++ b/tests/baselines/reference/returnInConstructor1.js @@ -70,8 +70,7 @@ class I extends G { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/returnStatements.js b/tests/baselines/reference/returnStatements.js index 35c208b19ee..956efc5f077 100644 --- a/tests/baselines/reference/returnStatements.js +++ b/tests/baselines/reference/returnStatements.js @@ -28,8 +28,7 @@ function fn13(): C { return null; } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // all the following should be valid function fn1() { return 1; } diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js index f971f089741..1a5fc7d9b3e 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js @@ -12,8 +12,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js index a7f7f4fde99..2844897bdd9 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js @@ -12,8 +12,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/scopeTests.js b/tests/baselines/reference/scopeTests.js index 99a933cf157..b104f63f74c 100644 --- a/tests/baselines/reference/scopeTests.js +++ b/tests/baselines/reference/scopeTests.js @@ -15,8 +15,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/shadowPrivateMembers.js b/tests/baselines/reference/shadowPrivateMembers.js index 4100dba13e3..e2ac679e7eb 100644 --- a/tests/baselines/reference/shadowPrivateMembers.js +++ b/tests/baselines/reference/shadowPrivateMembers.js @@ -7,8 +7,7 @@ class derived extends base { private n() {} } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var base = (function () { function base() { diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js index cae6e991e24..f210e65d4d2 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js @@ -11,8 +11,7 @@ class Greeter extends AbstractGreeter { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var AbstractGreeter = (function () { function AbstractGreeter() { diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map index 60a26845043..fad366e8ebb 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map] -{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts"],"names":["AbstractGreeter","AbstractGreeter.constructor","Greeter","Greeter.constructor"],"mappings":";;;;;;AAAA;IAAAA;IACAC,CAACA;IAADD,sBAACA;AAADA,CAACA,AADD,IACC;AAED;IAAsBE,2BAAeA;IAArCA;QAAsBC,8BAAeA;QAC1BA,MAACA,GAAGA,EAAEA,CAACA;QACPA,UAAKA,GAAGA,KAAKA,CAACA;IACzBA,CAACA;IAADD,cAACA;AAADA,CAACA,AAHD,EAAsB,eAAe,EAGpC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts"],"names":["AbstractGreeter","AbstractGreeter.constructor","Greeter","Greeter.constructor"],"mappings":";;;;;AAAA;IAAAA;IACAC,CAACA;IAADD,sBAACA;AAADA,CAACA,AADD,IACC;AAED;IAAsBE,2BAAeA;IAArCA;QAAsBC,8BAAeA;QAC1BA,MAACA,GAAGA,EAAEA,CAACA;QACPA,UAAKA,GAAGA,KAAKA,CAACA;IACzBA,CAACA;IAADD,cAACA;AAADA,CAACA,AAHD,EAAsB,eAAe,EAGpC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt index d0934f3c9ed..aba9861a230 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt @@ -11,20 +11,19 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts >>>var __extends = (this && this.__extends) || function (d, b) { >>> for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; >>> function __() { this.constructor = d; } ->>> __.prototype = b.prototype; ->>> d.prototype = new __(); +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); >>>}; >>>var AbstractGreeter = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(7, 1) Source(1, 1) + SourceIndex(0) +1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) --- >>> function AbstractGreeter() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(8, 5) Source(1, 1) + SourceIndex(0) name (AbstractGreeter) +1->Emitted(7, 5) Source(1, 1) + SourceIndex(0) name (AbstractGreeter) --- >>> } 1->^^^^ @@ -33,16 +32,16 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1->class AbstractGreeter { > 2 > } -1->Emitted(9, 5) Source(2, 1) + SourceIndex(0) name (AbstractGreeter.constructor) -2 >Emitted(9, 6) Source(2, 2) + SourceIndex(0) name (AbstractGreeter.constructor) +1->Emitted(8, 5) Source(2, 1) + SourceIndex(0) name (AbstractGreeter.constructor) +2 >Emitted(8, 6) Source(2, 2) + SourceIndex(0) name (AbstractGreeter.constructor) --- >>> return AbstractGreeter; 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > } -1->Emitted(10, 5) Source(2, 1) + SourceIndex(0) name (AbstractGreeter) -2 >Emitted(10, 27) Source(2, 2) + SourceIndex(0) name (AbstractGreeter) +1->Emitted(9, 5) Source(2, 1) + SourceIndex(0) name (AbstractGreeter) +2 >Emitted(9, 27) Source(2, 2) + SourceIndex(0) name (AbstractGreeter) --- >>>})(); 1 > @@ -55,10 +54,10 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > 4 > class AbstractGreeter { > } -1 >Emitted(11, 1) Source(2, 1) + SourceIndex(0) name (AbstractGreeter) -2 >Emitted(11, 2) Source(2, 2) + SourceIndex(0) name (AbstractGreeter) -3 >Emitted(11, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(11, 6) Source(2, 2) + SourceIndex(0) +1 >Emitted(10, 1) Source(2, 1) + SourceIndex(0) name (AbstractGreeter) +2 >Emitted(10, 2) Source(2, 2) + SourceIndex(0) name (AbstractGreeter) +3 >Emitted(10, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(10, 6) Source(2, 2) + SourceIndex(0) --- >>>var Greeter = (function (_super) { 1-> @@ -66,29 +65,29 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1-> > > -1->Emitted(12, 1) Source(4, 1) + SourceIndex(0) +1->Emitted(11, 1) Source(4, 1) + SourceIndex(0) --- >>> __extends(Greeter, _super); 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->class Greeter extends 2 > AbstractGreeter -1->Emitted(13, 5) Source(4, 23) + SourceIndex(0) name (Greeter) -2 >Emitted(13, 32) Source(4, 38) + SourceIndex(0) name (Greeter) +1->Emitted(12, 5) Source(4, 23) + SourceIndex(0) name (Greeter) +2 >Emitted(12, 32) Source(4, 38) + SourceIndex(0) name (Greeter) --- >>> function Greeter() { 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(14, 5) Source(4, 1) + SourceIndex(0) name (Greeter) +1 >Emitted(13, 5) Source(4, 1) + SourceIndex(0) name (Greeter) --- >>> _super.apply(this, arguments); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->class Greeter extends 2 > AbstractGreeter -1->Emitted(15, 9) Source(4, 23) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(15, 39) Source(4, 38) + SourceIndex(0) name (Greeter.constructor) +1->Emitted(14, 9) Source(4, 23) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(14, 39) Source(4, 38) + SourceIndex(0) name (Greeter.constructor) --- >>> this.a = 10; 1 >^^^^^^^^ @@ -103,11 +102,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > = 4 > 10 5 > ; -1 >Emitted(16, 9) Source(5, 12) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(16, 15) Source(5, 13) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(16, 18) Source(5, 16) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(16, 20) Source(5, 18) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(16, 21) Source(5, 19) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(15, 9) Source(5, 12) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(15, 15) Source(5, 13) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(15, 18) Source(5, 16) + SourceIndex(0) name (Greeter.constructor) +4 >Emitted(15, 20) Source(5, 18) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(15, 21) Source(5, 19) + SourceIndex(0) name (Greeter.constructor) --- >>> this.nameA = "Ten"; 1->^^^^^^^^ @@ -121,11 +120,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > = 4 > "Ten" 5 > ; -1->Emitted(17, 9) Source(6, 12) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(17, 19) Source(6, 17) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(17, 22) Source(6, 20) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(17, 27) Source(6, 25) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(17, 28) Source(6, 26) + SourceIndex(0) name (Greeter.constructor) +1->Emitted(16, 9) Source(6, 12) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(16, 19) Source(6, 17) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(16, 22) Source(6, 20) + SourceIndex(0) name (Greeter.constructor) +4 >Emitted(16, 27) Source(6, 25) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(16, 28) Source(6, 26) + SourceIndex(0) name (Greeter.constructor) --- >>> } 1 >^^^^ @@ -134,8 +133,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1 > > 2 > } -1 >Emitted(18, 5) Source(7, 1) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(18, 6) Source(7, 2) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(17, 5) Source(7, 1) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(17, 6) Source(7, 2) + SourceIndex(0) name (Greeter.constructor) --- >>> return Greeter; 1->^^^^ @@ -143,8 +142,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > ^^^-> 1-> 2 > } -1->Emitted(19, 5) Source(7, 1) + SourceIndex(0) name (Greeter) -2 >Emitted(19, 19) Source(7, 2) + SourceIndex(0) name (Greeter) +1->Emitted(18, 5) Source(7, 1) + SourceIndex(0) name (Greeter) +2 >Emitted(18, 19) Source(7, 2) + SourceIndex(0) name (Greeter) --- >>>})(AbstractGreeter); 1-> @@ -163,11 +162,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts > public a = 10; > public nameA = "Ten"; > } -1->Emitted(20, 1) Source(7, 1) + SourceIndex(0) name (Greeter) -2 >Emitted(20, 2) Source(7, 2) + SourceIndex(0) name (Greeter) -3 >Emitted(20, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(20, 4) Source(4, 23) + SourceIndex(0) -5 >Emitted(20, 19) Source(4, 38) + SourceIndex(0) -6 >Emitted(20, 21) Source(7, 2) + SourceIndex(0) +1->Emitted(19, 1) Source(7, 1) + SourceIndex(0) name (Greeter) +2 >Emitted(19, 2) Source(7, 2) + SourceIndex(0) name (Greeter) +3 >Emitted(19, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(19, 4) Source(4, 23) + SourceIndex(0) +5 >Emitted(19, 19) Source(4, 38) + SourceIndex(0) +6 >Emitted(19, 21) Source(7, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js b/tests/baselines/reference/sourceMapValidationDecorators.js index f858aeff586..5196d3b0dd8 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js +++ b/tests/baselines/reference/sourceMapValidationDecorators.js @@ -3,8 +3,8 @@ declare function ClassDecorator1(target: Function): void; declare function ClassDecorator2(x: number): (target: Function) => void; declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; -declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void; -declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void; +declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; +declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; @ClassDecorator1 @ClassDecorator2(10) diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index 68ad353db9f..b7036723a85 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -26,8 +26,8 @@ sourceFile:sourceMapValidationDecorators.ts >declare function ClassDecorator2(x: number): (target: Function) => void; >declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; >declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; - >declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void; - >declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void; + >declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; + >declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; > > 1 >Emitted(12, 1) Source(8, 1) + SourceIndex(0) diff --git a/tests/baselines/reference/sourceMapValidationDecorators.symbols b/tests/baselines/reference/sourceMapValidationDecorators.symbols index 37db95d3e05..e22afb7b7fc 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.symbols +++ b/tests/baselines/reference/sourceMapValidationDecorators.symbols @@ -27,20 +27,20 @@ declare function PropertyDecorator2(x: number): (target: Object, key: string | s >descriptor : Symbol(descriptor, Decl(sourceMapValidationDecorators.ts, 3, 86)) >PropertyDescriptor : Symbol(PropertyDescriptor, Decl(lib.d.ts, 79, 66)) -declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void; +declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; >ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128)) >target : Symbol(target, Decl(sourceMapValidationDecorators.ts, 4, 37)) ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) ->key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 4, 54)) ->paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 4, 76)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 4, 52)) +>paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 4, 74)) -declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void; ->ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103)) +declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; +>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101)) >x : Symbol(x, Decl(sourceMapValidationDecorators.ts, 5, 37)) >target : Symbol(target, Decl(sourceMapValidationDecorators.ts, 5, 50)) ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) ->key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 5, 67)) ->paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 5, 89)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>key : Symbol(key, Decl(sourceMapValidationDecorators.ts, 5, 65)) +>paramIndex : Symbol(paramIndex, Decl(sourceMapValidationDecorators.ts, 5, 87)) @ClassDecorator1 >ClassDecorator1 : Symbol(ClassDecorator1, Decl(sourceMapValidationDecorators.ts, 0, 0)) @@ -49,14 +49,14 @@ declare function ParameterDecorator2(x: number): (target: Function, key: string >ClassDecorator2 : Symbol(ClassDecorator2, Decl(sourceMapValidationDecorators.ts, 0, 57)) class Greeter { ->Greeter : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118)) +>Greeter : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116)) constructor( @ParameterDecorator1 >ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128)) @ParameterDecorator2(20) ->ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103)) +>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101)) public greeting: string, >greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) @@ -65,7 +65,7 @@ class Greeter { >ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128)) @ParameterDecorator2(30) ->ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103)) +>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101)) ...b: string[]) { >b : Symbol(b, Decl(sourceMapValidationDecorators.ts, 13, 30)) @@ -82,7 +82,7 @@ class Greeter { return "

" + this.greeting + "

"; >this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) ->this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118)) +>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116)) >greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) } @@ -111,14 +111,14 @@ class Greeter { >ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128)) @ParameterDecorator2(70) ->ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103)) +>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101)) x: number) { >x : Symbol(x, Decl(sourceMapValidationDecorators.ts, 34, 15)) return this.greeting; >this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) ->this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118)) +>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116)) >greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) } @@ -133,7 +133,7 @@ class Greeter { return this.greeting; >this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) ->this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118)) +>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116)) >greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) } @@ -144,14 +144,14 @@ class Greeter { >ParameterDecorator1 : Symbol(ParameterDecorator1, Decl(sourceMapValidationDecorators.ts, 3, 128)) @ParameterDecorator2(90) ->ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 103)) +>ParameterDecorator2 : Symbol(ParameterDecorator2, Decl(sourceMapValidationDecorators.ts, 4, 101)) greetings: string) { >greetings : Symbol(greetings, Decl(sourceMapValidationDecorators.ts, 47, 18)) this.greeting = greetings; >this.greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) ->this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 118)) +>this : Symbol(Greeter, Decl(sourceMapValidationDecorators.ts, 5, 116)) >greeting : Symbol(greeting, Decl(sourceMapValidationDecorators.ts, 10, 16)) >greetings : Symbol(greetings, Decl(sourceMapValidationDecorators.ts, 47, 18)) } diff --git a/tests/baselines/reference/sourceMapValidationDecorators.types b/tests/baselines/reference/sourceMapValidationDecorators.types index 182f68570bc..9e83bb03509 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.types +++ b/tests/baselines/reference/sourceMapValidationDecorators.types @@ -27,18 +27,18 @@ declare function PropertyDecorator2(x: number): (target: Object, key: string | s >descriptor : PropertyDescriptor >PropertyDescriptor : PropertyDescriptor -declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void; ->ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void ->target : Function ->Function : Function +declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; +>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void +>target : Object +>Object : Object >key : string | symbol >paramIndex : number -declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void; ->ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void +declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; +>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void >x : number ->target : Function ->Function : Function +>target : Object +>Object : Object >key : string | symbol >paramIndex : number @@ -55,22 +55,22 @@ class Greeter { constructor( @ParameterDecorator1 ->ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void @ParameterDecorator2(20) ->ParameterDecorator2(20) : (target: Function, key: string | symbol, paramIndex: number) => void ->ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2(20) : (target: Object, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void >20 : number public greeting: string, >greeting : string @ParameterDecorator1 ->ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void @ParameterDecorator2(30) ->ParameterDecorator2(30) : (target: Function, key: string | symbol, paramIndex: number) => void ->ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2(30) : (target: Object, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void >30 : number ...b: string[]) { @@ -125,11 +125,11 @@ class Greeter { >fn : (x: number) => string @ParameterDecorator1 ->ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void @ParameterDecorator2(70) ->ParameterDecorator2(70) : (target: Function, key: string | symbol, paramIndex: number) => void ->ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2(70) : (target: Object, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void >70 : number x: number) { @@ -162,11 +162,11 @@ class Greeter { >greetings : string @ParameterDecorator1 ->ParameterDecorator1 : (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator1 : (target: Object, key: string | symbol, paramIndex: number) => void @ParameterDecorator2(90) ->ParameterDecorator2(90) : (target: Function, key: string | symbol, paramIndex: number) => void ->ParameterDecorator2 : (x: number) => (target: Function, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2(90) : (target: Object, key: string | symbol, paramIndex: number) => void +>ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void >90 : number greetings: string) { diff --git a/tests/baselines/reference/specializedInheritedConstructors1.js b/tests/baselines/reference/specializedInheritedConstructors1.js index ec467ad9877..20ef13c3f09 100644 --- a/tests/baselines/reference/specializedInheritedConstructors1.js +++ b/tests/baselines/reference/specializedInheritedConstructors1.js @@ -21,8 +21,7 @@ var myView = new MyView(m); // was error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var View = (function () { function View(options) { diff --git a/tests/baselines/reference/specializedInheritedConstructors1.types b/tests/baselines/reference/specializedInheritedConstructors1.types index a073efa24d7..7a7c4782406 100644 --- a/tests/baselines/reference/specializedInheritedConstructors1.types +++ b/tests/baselines/reference/specializedInheritedConstructors1.types @@ -27,7 +27,7 @@ class Model { } class MyView extends View { } >MyView : MyView ->View : View +>View : View >Model : Model var m: ViewOptions = { model: new Model() }; diff --git a/tests/baselines/reference/specializedOverloadWithRestParameters.js b/tests/baselines/reference/specializedOverloadWithRestParameters.js index 2a022cdf7da..31cb4a69594 100644 --- a/tests/baselines/reference/specializedOverloadWithRestParameters.js +++ b/tests/baselines/reference/specializedOverloadWithRestParameters.js @@ -16,8 +16,7 @@ function g(tagName: any): Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/staticFactory1.js b/tests/baselines/reference/staticFactory1.js index 96303af586f..03092a16de9 100644 --- a/tests/baselines/reference/staticFactory1.js +++ b/tests/baselines/reference/staticFactory1.js @@ -17,8 +17,7 @@ d.foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/staticInheritance.js b/tests/baselines/reference/staticInheritance.js index 0aba29b3560..d3e14d482cc 100644 --- a/tests/baselines/reference/staticInheritance.js +++ b/tests/baselines/reference/staticInheritance.js @@ -15,8 +15,7 @@ doThing(B); //OK var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function doThing(x) { } var A = (function () { diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js index ab3c010d571..8f9849af057 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js @@ -13,8 +13,7 @@ class P extends SomeBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SomeBase = (function () { function SomeBase() { diff --git a/tests/baselines/reference/staticPropSuper.js b/tests/baselines/reference/staticPropSuper.js index f0d50b3ecb6..3f75dc8e26b 100644 --- a/tests/baselines/reference/staticPropSuper.js +++ b/tests/baselines/reference/staticPropSuper.js @@ -39,8 +39,7 @@ class E extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index fef1ef46b1a..7fd74aa108f 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -64,8 +64,7 @@ class Ds extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/strictModeReservedWord.errors.txt b/tests/baselines/reference/strictModeReservedWord.errors.txt index b6e9161ce7e..6f6a387429d 100644 --- a/tests/baselines/reference/strictModeReservedWord.errors.txt +++ b/tests/baselines/reference/strictModeReservedWord.errors.txt @@ -17,8 +17,8 @@ tests/cases/compiler/strictModeReservedWord.ts(13,11): error TS1212: Identifier tests/cases/compiler/strictModeReservedWord.ts(13,20): error TS1212: Identifier expected. 'public' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(13,28): error TS1212: Identifier expected. 'package' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(15,25): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWord.ts(15,25): error TS9003: 'class' expressions are not currently supported. tests/cases/compiler/strictModeReservedWord.ts(15,41): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. +tests/cases/compiler/strictModeReservedWord.ts(15,41): error TS2507: Type 'number' is not a constructor function type. tests/cases/compiler/strictModeReservedWord.ts(17,9): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS1212: Identifier expected. 'public' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS2503: Cannot find namespace 'public'. @@ -95,10 +95,10 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invok var myClass = class package extends public {} ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. - ~~~~~~~ -!!! error TS9003: 'class' expressions are not currently supported. ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. + ~~~~~~ +!!! error TS2507: Type 'number' is not a constructor function type. var b: public.bar; ~ diff --git a/tests/baselines/reference/strictModeReservedWord.js b/tests/baselines/reference/strictModeReservedWord.js index 9be21b20ae6..bec159dee6f 100644 --- a/tests/baselines/reference/strictModeReservedWord.js +++ b/tests/baselines/reference/strictModeReservedWord.js @@ -28,6 +28,11 @@ function foo() { //// [strictModeReservedWord.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; var let = 10; function foo() { "use strict"; diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt index 138d09e9b55..0b868960bed 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt @@ -22,7 +22,7 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error T tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2503: Cannot find namespace 'package'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2304: Cannot find name 'package'. ==== tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts (25 errors) ==== @@ -103,4 +103,4 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~~ -!!! error TS2503: Cannot find namespace 'package'. \ No newline at end of file +!!! error TS2304: Cannot find name 'package'. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js index 9ee817182c2..e4bef791374 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js @@ -32,8 +32,7 @@ class H extends package.A { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo(private, public, static) { diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js index b6bd2dbd437..97e3e9b0f5b 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js @@ -44,8 +44,7 @@ var b: { [x: string]: A } = { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/subtypesOfTypeParameter.js b/tests/baselines/reference/subtypesOfTypeParameter.js index 5abdd633424..c7b14a4129c 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.js +++ b/tests/baselines/reference/subtypesOfTypeParameter.js @@ -110,8 +110,7 @@ function f2(x: T, y: U) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C3 = (function () { function C3() { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js index afe9b998bd4..194c1835147 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js @@ -172,8 +172,7 @@ class D29 extends C3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C3 = (function () { function C3() { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js index 6f1756912a6..370bbf2b8ff 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js @@ -83,8 +83,7 @@ class D9 extends B1 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js index 3d2b6372302..c5d4e68b516 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js @@ -162,8 +162,7 @@ module M2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/subtypingTransitivity.js b/tests/baselines/reference/subtypingTransitivity.js index 9dcb4095aa2..9bc5cd93209 100644 --- a/tests/baselines/reference/subtypingTransitivity.js +++ b/tests/baselines/reference/subtypingTransitivity.js @@ -23,8 +23,7 @@ b.x = 1; // assigned number to string var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B() { diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.js b/tests/baselines/reference/subtypingWithCallSignatures2.js index db6f1d85954..f11b83c4da6 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.js +++ b/tests/baselines/reference/subtypingWithCallSignatures2.js @@ -177,8 +177,7 @@ var r18 = foo18(r18arg1); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.js b/tests/baselines/reference/subtypingWithCallSignatures3.js index d7ff8a79b6c..2b45b75b95f 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.js +++ b/tests/baselines/reference/subtypingWithCallSignatures3.js @@ -124,8 +124,7 @@ module WithGenericSignaturesInBaseType { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Errors; (function (Errors) { diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.js b/tests/baselines/reference/subtypingWithCallSignatures4.js index 739e3cacd86..d1d30437cd6 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.js +++ b/tests/baselines/reference/subtypingWithCallSignatures4.js @@ -116,8 +116,7 @@ var r18 = foo18(r18arg); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.js b/tests/baselines/reference/subtypingWithConstructSignatures2.js index 4e93ddbbe55..df050ffd6e9 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.js @@ -177,8 +177,7 @@ var r18 = foo18(r18arg1); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.js b/tests/baselines/reference/subtypingWithConstructSignatures3.js index 7022b4b395c..ccc6fb872c5 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.js @@ -126,8 +126,7 @@ module WithGenericSignaturesInBaseType { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Errors; (function (Errors) { diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.js b/tests/baselines/reference/subtypingWithConstructSignatures4.js index a16ea8e2397..67b83aa94c9 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.js @@ -116,8 +116,7 @@ var r18 = foo18(r18arg); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index fe3b86d1775..ec3bad2c1f3 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -54,8 +54,7 @@ interface I extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.js b/tests/baselines/reference/subtypingWithConstructSignatures6.js index 990b654bf45..1c7a2d883c3 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.js @@ -57,8 +57,7 @@ interface I9 extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithNumericIndexer.js b/tests/baselines/reference/subtypingWithNumericIndexer.js index a7790fba564..2ad6a2ebedc 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer.js @@ -44,8 +44,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt index 01b581b7306..318b64d9331 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(24,25): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(24,27): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } interface B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: number]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt index 4da8bc0290a..6f2684ae93b 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(24,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(24,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: number]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.js b/tests/baselines/reference/subtypingWithNumericIndexer3.js index c3fff86274f..f4c2d1d9da9 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.js @@ -48,8 +48,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt index f3c9cc25a10..5dd39e0ad63 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt @@ -6,7 +6,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'string' is not assignable to type 'Base'. Property 'foo' is missing in type 'String'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. !!! error TS2415: Property 'foo' is missing in type 'String'. - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. !!! error TS2344: Property 'bar' is missing in type 'Base'. [x: number]: string; // error diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.js b/tests/baselines/reference/subtypingWithNumericIndexer4.js index e7ec08436a7..7956464d172 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.js @@ -32,8 +32,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/subtypingWithObjectMembers.js b/tests/baselines/reference/subtypingWithObjectMembers.js index 28af7239222..fc452ba8cf4 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.js +++ b/tests/baselines/reference/subtypingWithObjectMembers.js @@ -71,8 +71,7 @@ module TwoLevels { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithObjectMembers4.js b/tests/baselines/reference/subtypingWithObjectMembers4.js index b04c3056a3e..487a5969f71 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers4.js +++ b/tests/baselines/reference/subtypingWithObjectMembers4.js @@ -38,8 +38,7 @@ class B3 extends A3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js index d3b62890855..f08f2367d2c 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js @@ -38,8 +38,7 @@ class B3 extends A3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js index 4a0ff448b7b..c23405cd50c 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js @@ -66,8 +66,7 @@ module ImplicitPublic { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/subtypingWithStringIndexer.js b/tests/baselines/reference/subtypingWithStringIndexer.js index 4b398451de8..5f606520a65 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer.js +++ b/tests/baselines/reference/subtypingWithStringIndexer.js @@ -45,8 +45,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt index cfe8f2b8e1d..82f6229b20c 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(24,25): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(24,27): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } interface B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: string]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt index 91c9f7fd47e..205ecf780cb 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(24,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(24,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: string]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.js b/tests/baselines/reference/subtypingWithStringIndexer3.js index cf1ec80a8d2..6ce66c4e723 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.js +++ b/tests/baselines/reference/subtypingWithStringIndexer3.js @@ -48,8 +48,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt index 6df716791c2..4aa889444e5 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt @@ -6,7 +6,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'string' is not assignable to type 'Base'. Property 'foo' is missing in type 'String'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. !!! error TS2415: Property 'foo' is missing in type 'String'. - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. !!! error TS2344: Property 'bar' is missing in type 'Base'. [x: string]: string; // error diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.js b/tests/baselines/reference/subtypingWithStringIndexer4.js index e6aa298fed8..19d36e475c2 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.js +++ b/tests/baselines/reference/subtypingWithStringIndexer4.js @@ -32,8 +32,7 @@ module Generics { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index ed220ae1f18..a6b698413ec 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -41,8 +41,7 @@ s.foo() + ss.foo(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index 1bf75783a60..6a52cfcd9e7 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -70,8 +70,7 @@ module Base4 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Case 1 var Base1 = (function () { diff --git a/tests/baselines/reference/super2.js b/tests/baselines/reference/super2.js index 0f5531a8d57..9d865194a2a 100644 --- a/tests/baselines/reference/super2.js +++ b/tests/baselines/reference/super2.js @@ -54,8 +54,7 @@ results1.x() + results1.y() + results2.y(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Case 5 var Base5 = (function () { diff --git a/tests/baselines/reference/superAccess.js b/tests/baselines/reference/superAccess.js index bf6a9ee3ad0..bb5a71a0b8f 100644 --- a/tests/baselines/reference/superAccess.js +++ b/tests/baselines/reference/superAccess.js @@ -17,8 +17,7 @@ class MyDerived extends MyBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var MyBase = (function () { function MyBase() { diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index afcba34aa5d..fd20f424ba3 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -28,8 +28,7 @@ class Q extends P { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var P = (function () { function P() { diff --git a/tests/baselines/reference/superAccessInFatArrow1.js b/tests/baselines/reference/superAccessInFatArrow1.js index 6222bf42fee..0dc69179c92 100644 --- a/tests/baselines/reference/superAccessInFatArrow1.js +++ b/tests/baselines/reference/superAccessInFatArrow1.js @@ -19,8 +19,7 @@ module test { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var test; (function (test) { diff --git a/tests/baselines/reference/superCallArgsMustMatch.js b/tests/baselines/reference/superCallArgsMustMatch.js index 7c7948cc387..3369cf7e8df 100644 --- a/tests/baselines/reference/superCallArgsMustMatch.js +++ b/tests/baselines/reference/superCallArgsMustMatch.js @@ -29,8 +29,7 @@ class T6 extends T5{ var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var T5 = (function () { function T5(bar) { diff --git a/tests/baselines/reference/superCallAssignResult.js b/tests/baselines/reference/superCallAssignResult.js index a83e5b3de75..24a198e3420 100644 --- a/tests/baselines/reference/superCallAssignResult.js +++ b/tests/baselines/reference/superCallAssignResult.js @@ -14,8 +14,7 @@ class H extends E { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var E = (function () { function E(arg) { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js index 15e26b5481f..d59f6f5a578 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js @@ -15,8 +15,7 @@ class D extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var D = (function (_super) { __extends(D, _super); diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types index 7630d67606a..02d85f763b5 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types @@ -16,7 +16,7 @@ declare class B { class D extends B { >D : D ->B : B +>B : B constructor() { super(); diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js index 15d24015a04..a3d5d42c822 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js @@ -14,8 +14,7 @@ class D extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var D = (function (_super) { __extends(D, _super); diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types index cd26719d22e..68959b8b4b6 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types @@ -12,7 +12,7 @@ declare class B { class D extends B { >D : D ->B : B +>B : B constructor() { super(); diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt index 14905b224ad..f491cac9f0c 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(8,17): error TS2314: Generic type 'A' requires 2 type argument(s). -tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class. -==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts (2 errors) ==== +==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts (1 errors) ==== class A { constructor(private map: (value: T1) => T2) { @@ -14,6 +13,4 @@ tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrec ~~~~~~~~~ !!! error TS2314: Generic type 'A' requires 2 type argument(s). constructor() { super(value => String(value)); } - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. } \ No newline at end of file diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js index 114505b85a2..155258861bf 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js @@ -14,8 +14,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(map) { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt index d402272df1b..32047f3b417 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(8,17): error TS2314: Generic type 'A' requires 2 type argument(s). -tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class. -==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts (2 errors) ==== +==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts (1 errors) ==== class A { constructor(private map: (value: T1) => T2) { @@ -14,6 +13,4 @@ tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeAr ~ !!! error TS2314: Generic type 'A' requires 2 type argument(s). constructor() { super(value => String(value)); } - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. } \ No newline at end of file diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js index 226665e3e67..37883b9921a 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js @@ -14,8 +14,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(map) { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.errors.txt b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.errors.txt index 8bbf8b87cd3..4aa9e5a134b 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.errors.txt +++ b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts(8,17): error TS2315: Type 'A' is not generic. -tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class. -==== tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts (2 errors) ==== +==== tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts (1 errors) ==== class A { constructor(private map: (value: number) => string) { @@ -14,6 +13,4 @@ tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArgum ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'A' is not generic. constructor() { super(value => String(value)); } - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. } \ No newline at end of file diff --git a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js index 7c07e78b0f9..dbd4528c39f 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js @@ -14,8 +14,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(map) { diff --git a/tests/baselines/reference/superCallInNonStaticMethod.js b/tests/baselines/reference/superCallInNonStaticMethod.js index c3038e23c4c..7de6a100451 100644 --- a/tests/baselines/reference/superCallInNonStaticMethod.js +++ b/tests/baselines/reference/superCallInNonStaticMethod.js @@ -54,8 +54,7 @@ class Other extends Doing { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Doing = (function () { function Doing() { diff --git a/tests/baselines/reference/superCallInStaticMethod.js b/tests/baselines/reference/superCallInStaticMethod.js index 7e57cd2d2e8..9978773739f 100644 --- a/tests/baselines/reference/superCallInStaticMethod.js +++ b/tests/baselines/reference/superCallInStaticMethod.js @@ -50,8 +50,7 @@ class Other extends Doing { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Doing = (function () { function Doing() { diff --git a/tests/baselines/reference/superCallOutsideConstructor.js b/tests/baselines/reference/superCallOutsideConstructor.js index 0a1822bc549..c2152e13db0 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.js +++ b/tests/baselines/reference/superCallOutsideConstructor.js @@ -26,8 +26,7 @@ var d = new D(); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superCallParameterContextualTyping1.js b/tests/baselines/reference/superCallParameterContextualTyping1.js index 4888473319e..b7508e4cd7d 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping1.js +++ b/tests/baselines/reference/superCallParameterContextualTyping1.js @@ -16,8 +16,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(map) { diff --git a/tests/baselines/reference/superCallParameterContextualTyping1.types b/tests/baselines/reference/superCallParameterContextualTyping1.types index 23aa3147997..4dc68fee3f7 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping1.types +++ b/tests/baselines/reference/superCallParameterContextualTyping1.types @@ -16,7 +16,7 @@ class A { class B extends A { >B : B ->A : A +>A : A // Ensure 'value' is of type 'number (and not '{}') by using its 'toExponential()' method. constructor() { super(value => String(value.toExponential())); } diff --git a/tests/baselines/reference/superCallParameterContextualTyping2.js b/tests/baselines/reference/superCallParameterContextualTyping2.js index ab6093c42be..996e0374c7f 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping2.js +++ b/tests/baselines/reference/superCallParameterContextualTyping2.js @@ -15,8 +15,7 @@ class C extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(map) { diff --git a/tests/baselines/reference/superCallParameterContextualTyping3.js b/tests/baselines/reference/superCallParameterContextualTyping3.js index 574d281ed09..6f1311e58ab 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping3.js +++ b/tests/baselines/reference/superCallParameterContextualTyping3.js @@ -35,8 +35,7 @@ class C extends CBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var CBase = (function () { function CBase(param) { diff --git a/tests/baselines/reference/superCallParameterContextualTyping3.types b/tests/baselines/reference/superCallParameterContextualTyping3.types index 4a8515d110c..262b624e78f 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping3.types +++ b/tests/baselines/reference/superCallParameterContextualTyping3.types @@ -29,7 +29,7 @@ class CBase { class C extends CBase { >C : C ->CBase : CBase +>CBase : CBase constructor() { // Should be okay. diff --git a/tests/baselines/reference/superCalls.js b/tests/baselines/reference/superCalls.js index d2e4f9ff7f1..bd54ba34b56 100644 --- a/tests/baselines/reference/superCalls.js +++ b/tests/baselines/reference/superCalls.js @@ -34,8 +34,7 @@ class OtherDerived extends OtherBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(n) { diff --git a/tests/baselines/reference/superCallsInConstructor.js b/tests/baselines/reference/superCallsInConstructor.js index 6bd313898d4..c238808b959 100644 --- a/tests/baselines/reference/superCallsInConstructor.js +++ b/tests/baselines/reference/superCallsInConstructor.js @@ -24,8 +24,7 @@ class Derived extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superErrors.js b/tests/baselines/reference/superErrors.js index 2e1cd346cd4..3a3de509120 100644 --- a/tests/baselines/reference/superErrors.js +++ b/tests/baselines/reference/superErrors.js @@ -55,8 +55,7 @@ class RegisteredUser extends User { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function foo() { // super in a non class context diff --git a/tests/baselines/reference/superInCatchBlock1.js b/tests/baselines/reference/superInCatchBlock1.js index 38131f5f08e..cf4c69c7b61 100644 --- a/tests/baselines/reference/superInCatchBlock1.js +++ b/tests/baselines/reference/superInCatchBlock1.js @@ -17,8 +17,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/superInConstructorParam1.js b/tests/baselines/reference/superInConstructorParam1.js index aaf4162e992..7c0cc7bf40d 100644 --- a/tests/baselines/reference/superInConstructorParam1.js +++ b/tests/baselines/reference/superInConstructorParam1.js @@ -14,8 +14,7 @@ class C extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var B = (function () { function B() { diff --git a/tests/baselines/reference/superInLambdas.js b/tests/baselines/reference/superInLambdas.js index 5640425f6bc..89d5798f882 100644 --- a/tests/baselines/reference/superInLambdas.js +++ b/tests/baselines/reference/superInLambdas.js @@ -71,8 +71,7 @@ class RegisteredUser4 extends User { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var User = (function () { function User() { diff --git a/tests/baselines/reference/superNewCall1.js b/tests/baselines/reference/superNewCall1.js index 1b11b61ce2f..aa25e65e14d 100644 --- a/tests/baselines/reference/superNewCall1.js +++ b/tests/baselines/reference/superNewCall1.js @@ -16,8 +16,7 @@ class B extends A { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A(map) { diff --git a/tests/baselines/reference/superPropertyAccess.js b/tests/baselines/reference/superPropertyAccess.js index 016fc09ff96..95dbb2f94e0 100644 --- a/tests/baselines/reference/superPropertyAccess.js +++ b/tests/baselines/reference/superPropertyAccess.js @@ -40,8 +40,7 @@ class MyDerived extends MyBase { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var MyBase = (function () { function MyBase() { diff --git a/tests/baselines/reference/superPropertyAccess1.js b/tests/baselines/reference/superPropertyAccess1.js index 1ee834f3495..748331af95f 100644 --- a/tests/baselines/reference/superPropertyAccess1.js +++ b/tests/baselines/reference/superPropertyAccess1.js @@ -31,8 +31,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superPropertyAccess2.js b/tests/baselines/reference/superPropertyAccess2.js index 0877cf23b9d..dccd4717ee0 100644 --- a/tests/baselines/reference/superPropertyAccess2.js +++ b/tests/baselines/reference/superPropertyAccess2.js @@ -31,8 +31,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superPropertyAccessNoError.js b/tests/baselines/reference/superPropertyAccessNoError.js index f8ee7f6d01b..44a6910a386 100644 --- a/tests/baselines/reference/superPropertyAccessNoError.js +++ b/tests/baselines/reference/superPropertyAccessNoError.js @@ -70,8 +70,7 @@ class SomeDerivedClass extends SomeBaseClass { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SomeBaseClass = (function () { function SomeBaseClass() { diff --git a/tests/baselines/reference/superWithGenericSpecialization.js b/tests/baselines/reference/superWithGenericSpecialization.js index 5cd85f90735..3d1ea0f77a9 100644 --- a/tests/baselines/reference/superWithGenericSpecialization.js +++ b/tests/baselines/reference/superWithGenericSpecialization.js @@ -18,8 +18,7 @@ var r2: number = d.y; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superWithGenericSpecialization.types b/tests/baselines/reference/superWithGenericSpecialization.types index 258615b309f..075362e8a29 100644 --- a/tests/baselines/reference/superWithGenericSpecialization.types +++ b/tests/baselines/reference/superWithGenericSpecialization.types @@ -11,7 +11,7 @@ class C { class D extends C { >D : D >T : T ->C : C +>C : C y: T; >y : T diff --git a/tests/baselines/reference/superWithGenerics.js b/tests/baselines/reference/superWithGenerics.js index 8ba6f878dc2..482c7ba0694 100644 --- a/tests/baselines/reference/superWithGenerics.js +++ b/tests/baselines/reference/superWithGenerics.js @@ -15,8 +15,7 @@ class D extends B { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var D = (function (_super) { __extends(D, _super); diff --git a/tests/baselines/reference/superWithGenerics.types b/tests/baselines/reference/superWithGenerics.types index 3a034b67f04..ddf2741e35c 100644 --- a/tests/baselines/reference/superWithGenerics.types +++ b/tests/baselines/reference/superWithGenerics.types @@ -16,7 +16,7 @@ declare class B { class D extends B { >D : D ->B : B +>B : B constructor() { super(); diff --git a/tests/baselines/reference/superWithTypeArgument.js b/tests/baselines/reference/superWithTypeArgument.js index 2e5ea93a47a..6d5690cd689 100644 --- a/tests/baselines/reference/superWithTypeArgument.js +++ b/tests/baselines/reference/superWithTypeArgument.js @@ -13,8 +13,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superWithTypeArgument2.js b/tests/baselines/reference/superWithTypeArgument2.js index c33497d58fd..588094cd864 100644 --- a/tests/baselines/reference/superWithTypeArgument2.js +++ b/tests/baselines/reference/superWithTypeArgument2.js @@ -13,8 +13,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/superWithTypeArgument3.js b/tests/baselines/reference/superWithTypeArgument3.js index 1266d97f264..8f0ba6c0861 100644 --- a/tests/baselines/reference/superWithTypeArgument3.js +++ b/tests/baselines/reference/superWithTypeArgument3.js @@ -17,8 +17,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js index 97fa57528cf..d2f240b766d 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js @@ -31,8 +31,7 @@ class SuperObjectTest extends F { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var ObjectLiteral; (function (ObjectLiteral) { diff --git a/tests/baselines/reference/switchStatements.js b/tests/baselines/reference/switchStatements.js index debd9a4d531..39a4b2c901d 100644 --- a/tests/baselines/reference/switchStatements.js +++ b/tests/baselines/reference/switchStatements.js @@ -59,8 +59,7 @@ switch (((x: T) => '')(1)) { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/systemModule13.js b/tests/baselines/reference/systemModule13.js new file mode 100644 index 00000000000..c66e123c738 --- /dev/null +++ b/tests/baselines/reference/systemModule13.js @@ -0,0 +1,21 @@ +//// [systemModule13.ts] + +export let [x,y,z] = [1, 2, 3]; +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +for ([x] of [[1]]) {} + +//// [systemModule13.js] +System.register([], function(exports_1) { + var x, y, z, z0, z1; + return { + setters:[], + execute: function() { + _a = [1, 2, 3], exports_1("x", x = _a[0]), exports_1("y", y = _a[1]), exports_1("z", z = _a[2]); + _b = { a: true, b: { c: "123" } }, exports_1("z0", z0 = _b.a), exports_1("z1", z1 = _b.b.c); + for (var _i = 0, _c = [[1]]; _i < _c.length; _i++) { + exports_1("x", x = _c[_i][0]); + } + } + } + var _a, _b; +}); diff --git a/tests/baselines/reference/systemModule13.symbols b/tests/baselines/reference/systemModule13.symbols new file mode 100644 index 00000000000..d9e64335c2b --- /dev/null +++ b/tests/baselines/reference/systemModule13.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/systemModule13.ts === + +export let [x,y,z] = [1, 2, 3]; +>x : Symbol(x, Decl(systemModule13.ts, 1, 12)) +>y : Symbol(y, Decl(systemModule13.ts, 1, 14)) +>z : Symbol(z, Decl(systemModule13.ts, 1, 16)) + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>z0 : Symbol(z0, Decl(systemModule13.ts, 2, 14)) +>z1 : Symbol(z1, Decl(systemModule13.ts, 2, 25)) +>a : Symbol(a, Decl(systemModule13.ts, 2, 36)) +>b : Symbol(b, Decl(systemModule13.ts, 2, 44)) +>c : Symbol(c, Decl(systemModule13.ts, 2, 49)) + +for ([x] of [[1]]) {} +>x : Symbol(x, Decl(systemModule13.ts, 1, 12)) + diff --git a/tests/baselines/reference/systemModule13.types b/tests/baselines/reference/systemModule13.types new file mode 100644 index 00000000000..35f22be98b8 --- /dev/null +++ b/tests/baselines/reference/systemModule13.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/systemModule13.ts === + +export let [x,y,z] = [1, 2, 3]; +>x : number +>y : number +>z : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : any +>z0 : boolean +>b : any +>c : any +>z1 : string +>{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } +>a : boolean +>true : boolean +>b : { c: string; } +>{c: "123"} : { c: string; } +>c : string +>"123" : string + +for ([x] of [[1]]) {} +>[x] : number[] +>x : number +>[[1]] : number[][] +>[1] : number[] +>1 : number + diff --git a/tests/baselines/reference/targetTypeBaseCalls.js b/tests/baselines/reference/targetTypeBaseCalls.js index bde689ba2c9..41673a62efd 100644 --- a/tests/baselines/reference/targetTypeBaseCalls.js +++ b/tests/baselines/reference/targetTypeBaseCalls.js @@ -22,8 +22,7 @@ class Bar extends Foo { constructor() { super(function(s) { s = 5 }) } } // err var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function foo(x) { } var Foo = (function () { diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index 055e0770dea..d6f24cbcfdc 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'any' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location. @@ -52,7 +52,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): class ErrClass3 extends this { ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Type 'any' is not a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index afce4ec0375..84b96404683 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -52,8 +52,7 @@ enum SomeEnum { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; //'this' in static member initializer var ErrClass1 = (function () { diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index 03c494cad45..df47901d771 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'any' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. @@ -53,7 +53,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod class ErrClass3 extends this { ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Type 'any' is not a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 8fcbe226437..7de94be9420 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -52,8 +52,7 @@ export = this; // Should be an error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; //'this' in static member initializer var ErrClass1 = (function () { diff --git a/tests/baselines/reference/thisInSuperCall.js b/tests/baselines/reference/thisInSuperCall.js index 3da6d9c8a68..f7d7ca4e4fd 100644 --- a/tests/baselines/reference/thisInSuperCall.js +++ b/tests/baselines/reference/thisInSuperCall.js @@ -26,8 +26,7 @@ class Foo3 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(x) { diff --git a/tests/baselines/reference/thisInSuperCall1.js b/tests/baselines/reference/thisInSuperCall1.js index b0ff1bd4bab..4ae43784fe0 100644 --- a/tests/baselines/reference/thisInSuperCall1.js +++ b/tests/baselines/reference/thisInSuperCall1.js @@ -14,8 +14,7 @@ class Foo extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(a) { diff --git a/tests/baselines/reference/thisInSuperCall2.js b/tests/baselines/reference/thisInSuperCall2.js index fca671a2c73..a9bbeda9fe7 100644 --- a/tests/baselines/reference/thisInSuperCall2.js +++ b/tests/baselines/reference/thisInSuperCall2.js @@ -23,8 +23,7 @@ class Foo2 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(a) { diff --git a/tests/baselines/reference/thisInSuperCall3.js b/tests/baselines/reference/thisInSuperCall3.js index fe2bdec77ed..ba27add2d97 100644 --- a/tests/baselines/reference/thisInSuperCall3.js +++ b/tests/baselines/reference/thisInSuperCall3.js @@ -16,8 +16,7 @@ class Foo extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(a) { diff --git a/tests/baselines/reference/tsxAttributeErrors.errors.txt b/tests/baselines/reference/tsxAttributeErrors.errors.txt new file mode 100644 index 00000000000..30a897c5163 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeErrors.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeErrors.tsx (3 errors) ==== + + declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } + } + + // Error, number is not assignable to string +
; + ~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // Error, string is not assignable to number +
; + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + // Error, number is not assignable to string + var attribs = { text: 100 }; +
; + ~~~~~~~~~~~~ +!!! error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // No errors here + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeErrors.js b/tests/baselines/reference/tsxAttributeErrors.js new file mode 100644 index 00000000000..2ab862e0efe --- /dev/null +++ b/tests/baselines/reference/tsxAttributeErrors.js @@ -0,0 +1,38 @@ +//// [tsxAttributeErrors.tsx] + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } +} + +// Error, number is not assignable to string +
; + +// Error, string is not assignable to number +
; + +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; + +// No errors here +; + + +//// [tsxAttributeErrors.jsx] +// Error, number is not assignable to string +
; +// Error, string is not assignable to number +
; +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; +// No errors here +; diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt new file mode 100644 index 00000000000..90d0d003c28 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,8): error TS1003: Identifier expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,10): error TS1005: ';' expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,10): error TS2304: Cannot find name 'data'. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,15): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,18): error TS1005: ':' expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,21): error TS1109: Expression expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,22): error TS1109: Expression expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,8): error TS1003: Identifier expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,9): error TS2304: Cannot find name 'data'. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,13): error TS1005: ';' expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,20): error TS1161: Unterminated regular expression literal. + + +==== tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx (12 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; + } + } + + // Invalid names + ; + ~~ +!!! error TS1003: Identifier expected. + ~~~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'data'. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1003: Identifier expected. + ~~~~ +!!! error TS2304: Cannot find name 'data'. + ~ +!!! error TS1005: ';' expected. + +!!! error TS1161: Unterminated regular expression literal. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.js b/tests/baselines/reference/tsxAttributeInvalidNames.js new file mode 100644 index 00000000000..af1de76995c --- /dev/null +++ b/tests/baselines/reference/tsxAttributeInvalidNames.js @@ -0,0 +1,23 @@ +//// [tsxAttributeInvalidNames.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; + } +} + +// Invalid names +; +; + +//// [tsxAttributeInvalidNames.jsx] +// Invalid names +; +32; +data = { 32: } / > ; + - data; +{ + 32; +} +/>;; diff --git a/tests/baselines/reference/tsxAttributeResolution.js b/tests/baselines/reference/tsxAttributeResolution.js new file mode 100644 index 00000000000..ed3915b7ff2 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.js @@ -0,0 +1,12 @@ +//// [tsxAttributeResolution.tsx] + +declare namespace JSX { + interface IntrinsicElements { + x: { y: number; z: string; }; + } +} + + + + +//// [tsxAttributeResolution.jsx] diff --git a/tests/baselines/reference/tsxAttributeResolution.symbols b/tests/baselines/reference/tsxAttributeResolution.symbols new file mode 100644 index 00000000000..a40be3861b3 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeResolution.tsx, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution.tsx, 1, 23)) + + x: { y: number; z: string; }; +>x : Symbol(x, Decl(tsxAttributeResolution.tsx, 2, 30)) +>y : Symbol(y, Decl(tsxAttributeResolution.tsx, 3, 6)) +>z : Symbol(z, Decl(tsxAttributeResolution.tsx, 3, 17)) + } +} + + + diff --git a/tests/baselines/reference/tsxAttributeResolution.types b/tests/baselines/reference/tsxAttributeResolution.types new file mode 100644 index 00000000000..f0adc582944 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution.tsx === + +declare namespace JSX { +>JSX : any + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + x: { y: number; z: string; }; +>x : { y: number; z: string; } +>y : number +>z : string + } +} + + + diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt new file mode 100644 index 00000000000..54666f46aba --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(22,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (6 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + } + } + interface Attribs1 { + x?: number; + s?: string; + } + + // OK + ; // OK + ; // OK + ; // OK + + ; // OK + ; // OK + + // Errors + ; // Error, '0' is not number + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ; // Error, no property "y" + ~ +!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ; // Error, no property "y" + ~ +!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ; // Error, "32" is not number + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + // TODO attribute 'var' should be parseable + // ; // Error, no 'var' property + + ; // Error, missing reqd + ~~~~~~~~~ +!!! error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. + ; // Error, reqd is not string + ~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution1.js b/tests/baselines/reference/tsxAttributeResolution1.js new file mode 100644 index 00000000000..011ac8034e2 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution1.js @@ -0,0 +1,50 @@ +//// [tsxAttributeResolution1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + } +} +interface Attribs1 { + x?: number; + s?: string; +} + +// OK +; // OK +; // OK +; // OK + +; // OK +; // OK + +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property + +; // Error, missing reqd +; // Error, reqd is not string + + + +//// [tsxAttributeResolution1.jsx] +// OK +; // OK +; // OK +; // OK +; // OK +; // OK +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property +; // Error, missing reqd +; // Error, reqd is not string diff --git a/tests/baselines/reference/tsxAttributeResolution2.errors.txt b/tests/baselines/reference/tsxAttributeResolution2.errors.txt new file mode 100644 index 00000000000..d213ccaf54e --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution2.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/jsx/tsxAttributeResolution2.tsx(17,21): error TS2339: Property 'leng' does not exist on type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution2.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + c1?: (x: string) => void; + } + + // OK + x.length} />; // OK + x.leng} />; // OK + + + // Errors + x.leng} />; // Error, no leng on 'string' + ~~~~ +!!! error TS2339: Property 'leng' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution2.js b/tests/baselines/reference/tsxAttributeResolution2.js new file mode 100644 index 00000000000..564767e6169 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution2.js @@ -0,0 +1,26 @@ +//// [tsxAttributeResolution2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + c1?: (x: string) => void; +} + +// OK + x.length} />; // OK + x.leng} />; // OK + + +// Errors + x.leng} />; // Error, no leng on 'string' + + +//// [tsxAttributeResolution2.jsx] +// OK +; // OK +; // OK +// Errors +; // Error, no leng on 'string' diff --git a/tests/baselines/reference/tsxAttributeResolution3.errors.txt b/tests/baselines/reference/tsxAttributeResolution3.errors.txt new file mode 100644 index 00000000000..c797362e8d7 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution3.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(19,8): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(23,1): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(31,15): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(39,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution3.tsx (4 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + x: string; + y?: number; + z?: string; + } + + // OK + var obj1 = { x: 'foo' }; + + + // Error, x is not string + var obj2 = { x: 32 }; + + ~~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // Error, x is missing + var obj3 = { y: 32 }; + + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + + // OK + var obj4 = { x: 32, y: 32 }; + + + // Error + var obj5 = { x: 32, y: 32 }; + + ~~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // OK + var obj6 = { x: 'ok', y: 32, extra: 100 }; + + + // Error + var obj7 = { x: 'foo' }; + + ~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution3.js b/tests/baselines/reference/tsxAttributeResolution3.js new file mode 100644 index 00000000000..8cf853820e1 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution3.js @@ -0,0 +1,64 @@ +//// [tsxAttributeResolution3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x: string; + y?: number; + z?: string; +} + +// OK +var obj1 = { x: 'foo' }; + + +// Error, x is not string +var obj2 = { x: 32 }; + + +// Error, x is missing +var obj3 = { y: 32 }; + + +// OK +var obj4 = { x: 32, y: 32 }; + + +// Error +var obj5 = { x: 32, y: 32 }; + + +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; + + +// Error +var obj7 = { x: 'foo' }; + + + +//// [tsxAttributeResolution3.jsx] +// OK +var obj1 = { x: 'foo' }; +; +// Error, x is not string +var obj2 = { x: 32 }; +; +// Error, x is missing +var obj3 = { y: 32 }; +; +// OK +var obj4 = { x: 32, y: 32 }; +; +// Error +var obj5 = { x: 32, y: 32 }; +; +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; +; +// Error +var obj7 = { x: 'foo' }; +; diff --git a/tests/baselines/reference/tsxAttributeResolution4.errors.txt b/tests/baselines/reference/tsxAttributeResolution4.errors.txt new file mode 100644 index 00000000000..211a349b304 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution4.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/jsx/tsxAttributeResolution4.tsx(15,26): error TS2339: Property 'len' does not exist on type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution4.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + x(n: string): void; + } + + // OK + 0} } />; + + // Error, no member 'len' on 'string' + n.len} } />; + ~~~ +!!! error TS2339: Property 'len' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution4.js b/tests/baselines/reference/tsxAttributeResolution4.js new file mode 100644 index 00000000000..d56cb4cc2e8 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution4.js @@ -0,0 +1,23 @@ +//// [tsxAttributeResolution4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x(n: string): void; +} + +// OK + 0} } />; + +// Error, no member 'len' on 'string' + n.len} } />; + + +//// [tsxAttributeResolution4.jsx] +// OK +; +// Error, no member 'len' on 'string' +; diff --git a/tests/baselines/reference/tsxAttributeResolution5.errors.txt b/tests/baselines/reference/tsxAttributeResolution5.errors.txt new file mode 100644 index 00000000000..1b42dd01465 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution5.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(21,16): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution5.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } + } + interface Attribs1 { + x: string; + } + + interface Attribs2 { + toString(): string; + } + + function make1 (obj: T) { + return ; // OK + } + + function make2 (obj: T) { + return ; // Error (x is number, not string) + ~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + } + + function make3 (obj: T) { + return ; // Error, missing x + ~~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + } + + + ; // Error, missing x + ~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution5.js b/tests/baselines/reference/tsxAttributeResolution5.js new file mode 100644 index 00000000000..34fe9a3bfb6 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution5.js @@ -0,0 +1,45 @@ +//// [tsxAttributeResolution5.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } +} +interface Attribs1 { + x: string; +} + +interface Attribs2 { + toString(): string; +} + +function make1 (obj: T) { + return ; // OK +} + +function make2 (obj: T) { + return ; // Error (x is number, not string) +} + +function make3 (obj: T) { + return ; // Error, missing x +} + + +; // Error, missing x +; // OK + + +//// [tsxAttributeResolution5.jsx] +function make1(obj) { + return ; // OK +} +function make2(obj) { + return ; // Error (x is number, not string) +} +function make3(obj) { + return ; // Error, missing x +} +; // Error, missing x +; // OK diff --git a/tests/baselines/reference/tsxAttributeResolution6.errors.txt b/tests/baselines/reference/tsxAttributeResolution6.errors.txt new file mode 100644 index 00000000000..4f1960358a5 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution6.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(10,8): error TS2322: Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(11,8): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: boolean; }'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution6.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } + } + + // Error + ; + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + ; + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + ; + ~~~~~~~~~ +!!! error TS2324: Property 'n' is missing in type '{ n: boolean; }'. + + // OK + ; + ; + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution6.js b/tests/baselines/reference/tsxAttributeResolution6.js new file mode 100644 index 00000000000..f4af0ba875a --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution6.js @@ -0,0 +1,29 @@ +//// [tsxAttributeResolution6.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } +} + +// Error +; +; +; + +// OK +; +; +; + + +//// [tsxAttributeResolution6.jsx] +// Error +; +; +; +// OK +; +; +; diff --git a/tests/baselines/reference/tsxAttributeResolution7.errors.txt b/tests/baselines/reference/tsxAttributeResolution7.errors.txt new file mode 100644 index 00000000000..4d05254ace8 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution7.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/jsx/tsxAttributeResolution7.tsx(9,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution7.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } + } + + // Error + ; + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // OK + ; + ; + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution7.js b/tests/baselines/reference/tsxAttributeResolution7.js new file mode 100644 index 00000000000..7ebd2e8f4db --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution7.js @@ -0,0 +1,24 @@ +//// [tsxAttributeResolution7.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Error +; + +// OK +; +; +; + + +//// [tsxAttributeResolution7.jsx] +// Error +; +// OK +; +; +; diff --git a/tests/baselines/reference/tsxAttributeResolution8.js b/tests/baselines/reference/tsxAttributeResolution8.js new file mode 100644 index 00000000000..50fff6c80fd --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.js @@ -0,0 +1,16 @@ +//// [tsxAttributeResolution8.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: {x: string}; + } +} + +var x: any; +// Should be OK + + +//// [tsxAttributeResolution8.jsx] +var x; +// Should be OK +; diff --git a/tests/baselines/reference/tsxAttributeResolution8.symbols b/tests/baselines/reference/tsxAttributeResolution8.symbols new file mode 100644 index 00000000000..9bb09c6cd85 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution8.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeResolution8.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxAttributeResolution8.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution8.tsx, 1, 22)) + + test1: {x: string}; +>test1 : Symbol(test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 3, 10)) + } +} + +var x: any; +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 7, 3)) + +// Should be OK + +>test1 : Symbol(JSX.IntrinsicElements.test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxAttributeResolution8.types b/tests/baselines/reference/tsxAttributeResolution8.types new file mode 100644 index 00000000000..db89d6678b6 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution8.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + test1: {x: string}; +>test1 : { x: string; } +>x : string + } +} + +var x: any; +>x : any + +// Should be OK + +> : JSX.Element +>test1 : any +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution.js b/tests/baselines/reference/tsxElementResolution.js new file mode 100644 index 00000000000..e7a4ae95e94 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.js @@ -0,0 +1,55 @@ +//// [tsxElementResolution.tsx] + +declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } +} + +class foundFirst { } +class Other {} + +module Dotted { + export class Name { } +} + +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; + + +//// [tsxElementResolution.jsx] +var foundFirst = (function () { + function foundFirst() { + } + return foundFirst; +})(); +var Other = (function () { + function Other() { + } + return Other; +})(); +var Dotted; +(function (Dotted) { + var Name = (function () { + function Name() { + } + return Name; + })(); + Dotted.Name = Name; +})(Dotted || (Dotted = {})); +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; diff --git a/tests/baselines/reference/tsxElementResolution.symbols b/tests/baselines/reference/tsxElementResolution.symbols new file mode 100644 index 00000000000..4cdd0c23cf1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/jsx/tsxElementResolution.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution.tsx, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution.tsx, 1, 23)) + + foundFirst: { x: string }; +>foundFirst : Symbol(foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) + + 'string_named'; + 'var'; + } +} + +class foundFirst { } +>foundFirst : Symbol(foundFirst, Decl(tsxElementResolution.tsx, 7, 1)) + +class Other {} +>Other : Symbol(Other, Decl(tsxElementResolution.tsx, 9, 20)) + +module Dotted { +>Dotted : Symbol(Dotted, Decl(tsxElementResolution.tsx, 10, 14)) + + export class Name { } +>Name : Symbol(Name, Decl(tsxElementResolution.tsx, 12, 15)) +} + +// Should find the intrinsic element, not the class element +var a = ; +>a : Symbol(a, Decl(tsxElementResolution.tsx, 17, 3)) +>foundFirst : Symbol(JSX.IntrinsicElements.foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) + +var b = ; +>b : Symbol(b, Decl(tsxElementResolution.tsx, 18, 3)) +>string_named : Symbol(JSX.IntrinsicElements.'string_named', Decl(tsxElementResolution.tsx, 3, 28)) + +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +>d : Symbol(d, Decl(tsxElementResolution.tsx, 22, 3)) +>Other : Symbol(Other, Decl(tsxElementResolution.tsx, 9, 20)) + +var e = ; +>e : Symbol(e, Decl(tsxElementResolution.tsx, 23, 3)) +>Name : Symbol(Dotted.Name, Decl(tsxElementResolution.tsx, 12, 15)) + diff --git a/tests/baselines/reference/tsxElementResolution.types b/tests/baselines/reference/tsxElementResolution.types new file mode 100644 index 00000000000..89600bbbc2f --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/jsx/tsxElementResolution.tsx === + +declare namespace JSX { +>JSX : any + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + foundFirst: { x: string }; +>foundFirst : { x: string; } +>x : string + + 'string_named'; + 'var'; + } +} + +class foundFirst { } +>foundFirst : foundFirst + +class Other {} +>Other : Other + +module Dotted { +>Dotted : typeof Dotted + + export class Name { } +>Name : Name +} + +// Should find the intrinsic element, not the class element +var a = ; +>a : any +> : any +>foundFirst : typeof foundFirst +>x : any + +var b = ; +>b : any +> : any +>string_named : any + +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +>d : any +> : any +>Other : typeof Other + +var e = ; +>e : any +> : any +>Dotted : any +>Name : any + diff --git a/tests/baselines/reference/tsxElementResolution1.errors.txt b/tests/baselines/reference/tsxElementResolution1.errors.txt new file mode 100644 index 00000000000..b54430bd106 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution1.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution1.tsx(12,1): error TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxElementResolution1.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } + } + + // OK +
; + + // Fail + ; + ~~~~~~~~ +!!! error TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution1.js b/tests/baselines/reference/tsxElementResolution1.js new file mode 100644 index 00000000000..c7e0536bde2 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution1.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +// OK +
; + +// Fail +; + +//// [tsxElementResolution1.jsx] +// OK +
; +// Fail +; diff --git a/tests/baselines/reference/tsxElementResolution10.errors.txt b/tests/baselines/reference/tsxElementResolution10.errors.txt new file mode 100644 index 00000000000..6dcee7d18fa --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution10.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/jsx/tsxElementResolution10.tsx(13,1): error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements. + Property 'render' is missing in type '{ x: number; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution10.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): { x: number }; + } + var Obj1: Obj1type; + ; // Error, no render member + ~~~~~~~~~~~~~~~ +!!! error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements. +!!! error TS2605: Property 'render' is missing in type '{ x: number; }'. + + interface Obj2type { + (n: string): { x: number; render: any; }; + } + var Obj2: Obj2type; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution10.js b/tests/baselines/reference/tsxElementResolution10.js new file mode 100644 index 00000000000..84c8619ab96 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution10.js @@ -0,0 +1,27 @@ +//// [tsxElementResolution10.tsx] +declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): { x: number }; +} +var Obj1: Obj1type; +; // Error, no render member + +interface Obj2type { + (n: string): { x: number; render: any; }; +} +var Obj2: Obj2type; +; // OK + + +//// [tsxElementResolution10.jsx] +var Obj1; +; // Error, no render member +var Obj2; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution11.errors.txt b/tests/baselines/reference/tsxElementResolution11.errors.txt new file mode 100644 index 00000000000..4f3ee00d82f --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution11.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxElementResolution11.tsx(17,7): error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution11.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): any; + } + var Obj1: Obj1type; + ; // OK + + interface Obj2type { + new(n: string): { q?: number }; + } + var Obj2: Obj2type; + ; // Error + ~ +!!! error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + + interface Obj3type { + new(n: string): { x: number; }; + } + var Obj3: Obj3type; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution11.js b/tests/baselines/reference/tsxElementResolution11.js new file mode 100644 index 00000000000..fb8572116b1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution11.js @@ -0,0 +1,33 @@ +//// [tsxElementResolution11.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number }; +} +var Obj2: Obj2type; +; // Error + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // OK + + +//// [tsxElementResolution11.jsx] +var Obj1; +; // OK +var Obj2; +; // Error +var Obj3; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution12.errors.txt b/tests/baselines/reference/tsxElementResolution12.errors.txt new file mode 100644 index 00000000000..71a22b502aa --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution12.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/jsx/tsxElementResolution12.tsx(17,2): error TS2304: Cannot find name 'Obj2'. +tests/cases/conformance/jsx/tsxElementResolution12.tsx(23,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property +tests/cases/conformance/jsx/tsxElementResolution12.tsx(30,7): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/jsx/tsxElementResolution12.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): any; + } + var Obj1: Obj1type; + ; // OK + + interface Obj2type { + new(n: string): { q?: number; pr: any }; + } + var obj2: Obj2type; + ; // OK + ~~~~ +!!! error TS2304: Cannot find name 'Obj2'. + + interface Obj3type { + new(n: string): { x: number; }; + } + var Obj3: Obj3type; + ; // Error + ~~~~~~~~~~~~~~~ +!!! error TS2607: JSX element class does not support attributes because it does not have a 'pr' property + + interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; + } + var Obj4: Obj4type; + ; // OK + ; // Error + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution12.js b/tests/baselines/reference/tsxElementResolution12.js new file mode 100644 index 00000000000..12973efdda7 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution12.js @@ -0,0 +1,43 @@ +//// [tsxElementResolution12.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number; pr: any }; +} +var obj2: Obj2type; +; // OK + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // Error + +interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; +} +var Obj4: Obj4type; +; // OK +; // Error + + +//// [tsxElementResolution12.jsx] +var Obj1; +; // OK +var obj2; +; // OK +var Obj3; +; // Error +var Obj4; +; // OK +; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.js b/tests/baselines/reference/tsxElementResolution13.js new file mode 100644 index 00000000000..f8631bdec0c --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.js @@ -0,0 +1,16 @@ +//// [tsxElementResolution13.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } +} + +interface Obj1 { + new(n: string): any; +} +var obj1: Obj1; +; // Error + + +//// [tsxElementResolution13.jsx] +var obj1; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.symbols b/tests/baselines/reference/tsxElementResolution13.symbols new file mode 100644 index 00000000000..4022602e53a --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsx/tsxElementResolution13.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution13.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution13.tsx, 0, 20)) + + interface ElementAttributesProperty { pr1: any; pr2: any; } +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(tsxElementResolution13.tsx, 1, 22)) +>pr1 : Symbol(pr1, Decl(tsxElementResolution13.tsx, 2, 38)) +>pr2 : Symbol(pr2, Decl(tsxElementResolution13.tsx, 2, 48)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution13.tsx, 3, 1)) + + new(n: string): any; +>n : Symbol(n, Decl(tsxElementResolution13.tsx, 6, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution13.tsx, 8, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution13.tsx, 3, 1)) + +; // Error +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types new file mode 100644 index 00000000000..cd6265de091 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxElementResolution13.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface ElementAttributesProperty { pr1: any; pr2: any; } +>ElementAttributesProperty : ElementAttributesProperty +>pr1 : any +>pr2 : any +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): any; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // Error +> : JSX.Element +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution14.js b/tests/baselines/reference/tsxElementResolution14.js new file mode 100644 index 00000000000..e1e440db5f3 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.js @@ -0,0 +1,15 @@ +//// [tsxElementResolution14.tsx] +declare module JSX { + interface Element { } +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // OK + + +//// [tsxElementResolution14.jsx] +var obj1; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution14.symbols b/tests/baselines/reference/tsxElementResolution14.symbols new file mode 100644 index 00000000000..58236a4e462 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxElementResolution14.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution14.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution14.tsx, 0, 20)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution14.tsx, 2, 1)) + + new(n: string): {}; +>n : Symbol(n, Decl(tsxElementResolution14.tsx, 5, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution14.tsx, 7, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution14.tsx, 2, 1)) + +; // OK +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types new file mode 100644 index 00000000000..ef03187d28e --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxElementResolution14.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): {}; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // OK +> : JSX.Element +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution15.errors.txt b/tests/baselines/reference/tsxElementResolution15.errors.txt new file mode 100644 index 00000000000..24480ab7f2b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution15.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution15.tsx(3,12): error TS2608: The global type 'JSX.ElementAttributesProperty' may not have more than one property + + +==== tests/cases/conformance/jsx/tsxElementResolution15.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2608: The global type 'JSX.ElementAttributesProperty' may not have more than one property + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): {}; + } + var Obj1: Obj1type; + ; // Error + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution15.js b/tests/baselines/reference/tsxElementResolution15.js new file mode 100644 index 00000000000..831b3a54b41 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution15.js @@ -0,0 +1,17 @@ +//// [tsxElementResolution15.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): {}; +} +var Obj1: Obj1type; +; // Error + + +//// [tsxElementResolution15.jsx] +var Obj1; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution16.errors.txt b/tests/baselines/reference/tsxElementResolution16.errors.txt new file mode 100644 index 00000000000..0e30cad9673 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist. +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + + +==== tests/cases/conformance/jsx/tsxElementResolution16.tsx (2 errors) ==== + declare module JSX { + } + + interface Obj1 { + new(n: string): {}; + } + var obj1: Obj1; + ; // Error (JSX.Element is implicit any) + ~~~~~~~~~~~~~~~ +!!! error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist. + ~~~~~~~~~~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution16.js b/tests/baselines/reference/tsxElementResolution16.js new file mode 100644 index 00000000000..1961215fa05 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.js @@ -0,0 +1,14 @@ +//// [tsxElementResolution16.tsx] +declare module JSX { +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // Error (JSX.Element is implicit any) + + +//// [tsxElementResolution16.jsx] +var obj1; +; // Error (JSX.Element is implicit any) diff --git a/tests/baselines/reference/tsxElementResolution17.js b/tests/baselines/reference/tsxElementResolution17.js new file mode 100644 index 00000000000..cd8d7e13beb --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution17.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +declare module 'elements1' { + class MyElement { + + } +} + +declare module 'elements2' { + class MyElement { + + } +} + +//// [consumer.tsx] +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +import s2 = require('elements2'); +; + + +//// [file.jsx] +//// [consumer.jsx] +define(["require", "exports", 'elements1'], function (require, exports, s1) { + ; +}); diff --git a/tests/baselines/reference/tsxElementResolution17.symbols b/tests/baselines/reference/tsxElementResolution17.symbols new file mode 100644 index 00000000000..0b4459552de --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/consumer.tsx === +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +>s1 : Symbol(s1, Decl(consumer.tsx, 0, 0)) + +import s2 = require('elements2'); +>s2 : Symbol(s2, Decl(consumer.tsx, 2, 33)) + +; +>MyElement : Symbol(s1.MyElement, Decl(file.tsx, 6, 28)) + +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) +} + +declare module 'elements1' { + class MyElement { +>MyElement : Symbol(MyElement, Decl(file.tsx, 6, 28)) + + } +} + +declare module 'elements2' { + class MyElement { +>MyElement : Symbol(MyElement, Decl(file.tsx, 12, 28)) + + } +} + diff --git a/tests/baselines/reference/tsxElementResolution17.types b/tests/baselines/reference/tsxElementResolution17.types new file mode 100644 index 00000000000..e6396a9a60b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsx/consumer.tsx === +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +>s1 : typeof s1 + +import s2 = require('elements2'); +>s2 : typeof s2 + +; +> : JSX.Element +>s1 : any +>MyElement : any + +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +declare module 'elements1' { + class MyElement { +>MyElement : MyElement + + } +} + +declare module 'elements2' { + class MyElement { +>MyElement : MyElement + + } +} + diff --git a/tests/baselines/reference/tsxElementResolution18.errors.txt b/tests/baselines/reference/tsxElementResolution18.errors.txt new file mode 100644 index 00000000000..a4728b2f749 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution18.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsx/tsxElementResolution18.tsx(6,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + + +==== tests/cases/conformance/jsx/tsxElementResolution18.tsx (1 errors) ==== + declare module JSX { + interface Element { } + } + + // Error under implicit any +
; + ~~~~~~~~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution18.js b/tests/baselines/reference/tsxElementResolution18.js new file mode 100644 index 00000000000..0b5138b7b49 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution18.js @@ -0,0 +1,12 @@ +//// [tsxElementResolution18.tsx] +declare module JSX { + interface Element { } +} + +// Error under implicit any +
; + + +//// [tsxElementResolution18.jsx] +// Error under implicit any +
; diff --git a/tests/baselines/reference/tsxElementResolution2.js b/tests/baselines/reference/tsxElementResolution2.js new file mode 100644 index 00000000000..1d06656d529 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: any; + } +} + +// OK +
; + +// OK +; + +//// [tsxElementResolution2.jsx] +// OK +
; +// OK +; diff --git a/tests/baselines/reference/tsxElementResolution2.symbols b/tests/baselines/reference/tsxElementResolution2.symbols new file mode 100644 index 00000000000..2935bcd4f63 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxElementResolution2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + + [x: string]: any; +>x : Symbol(x, Decl(tsxElementResolution2.tsx, 3, 6)) + } +} + +// OK +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + +// OK +; +>span : Symbol(JSX.IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxElementResolution2.types b/tests/baselines/reference/tsxElementResolution2.types new file mode 100644 index 00000000000..56ea5158253 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxElementResolution2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [x: string]: any; +>x : string + } +} + +// OK +
; +>
: JSX.Element +>div : any + +// OK +; +> : JSX.Element +>span : any + diff --git a/tests/baselines/reference/tsxElementResolution3.errors.txt b/tests/baselines/reference/tsxElementResolution3.errors.txt new file mode 100644 index 00000000000..bc3c7c5ebfc --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution3.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/jsx/tsxElementResolution3.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: string; }'. +tests/cases/conformance/jsx/tsxElementResolution3.tsx(12,7): error TS2339: Property 'w' does not exist on type '{ n: string; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution3.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } + } + + // OK +
; + + // Error + ; + ~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'n' is missing in type '{ n: string; }'. + ~ +!!! error TS2339: Property 'w' does not exist on type '{ n: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution3.js b/tests/baselines/reference/tsxElementResolution3.js new file mode 100644 index 00000000000..607d1c5ec66 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution3.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } +} + +// OK +
; + +// Error +; + +//// [tsxElementResolution3.jsx] +// OK +
; +// Error +; diff --git a/tests/baselines/reference/tsxElementResolution4.errors.txt b/tests/baselines/reference/tsxElementResolution4.errors.txt new file mode 100644 index 00000000000..0e383af5e7b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution4.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/jsx/tsxElementResolution4.tsx(16,1): error TS2324: Property 'm' is missing in type '{ m: string; }'. +tests/cases/conformance/jsx/tsxElementResolution4.tsx(16,7): error TS2339: Property 'q' does not exist on type '{ m: string; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution4.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } + } + + // OK +
; + + // OK + ; + + // Error + ; + ~~~~~~~~~~~~~ +!!! error TS2324: Property 'm' is missing in type '{ m: string; }'. + ~ +!!! error TS2339: Property 'q' does not exist on type '{ m: string; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution4.js b/tests/baselines/reference/tsxElementResolution4.js new file mode 100644 index 00000000000..ea395cb5077 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution4.js @@ -0,0 +1,26 @@ +//// [tsxElementResolution4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } +} + +// OK +
; + +// OK +; + +// Error +; + + +//// [tsxElementResolution4.jsx] +// OK +
; +// OK +; +// Error +; diff --git a/tests/baselines/reference/tsxElementResolution5.js b/tests/baselines/reference/tsxElementResolution5.js new file mode 100644 index 00000000000..8aadfec0f78 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.js @@ -0,0 +1,12 @@ +//// [tsxElementResolution5.tsx] +declare module JSX { + interface Element { } +} + +// OK, but implicit any +
; + + +//// [tsxElementResolution5.jsx] +// OK, but implicit any +
; diff --git a/tests/baselines/reference/tsxElementResolution5.symbols b/tests/baselines/reference/tsxElementResolution5.symbols new file mode 100644 index 00000000000..8bbbfaaeb68 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsx/tsxElementResolution5.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution5.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution5.tsx, 0, 20)) +} + +// OK, but implicit any +
; +>n : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution5.types b/tests/baselines/reference/tsxElementResolution5.types new file mode 100644 index 00000000000..ba3509f4fa1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsx/tsxElementResolution5.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +// OK, but implicit any +
; +>
: JSX.Element +>div : any +>n : any + diff --git a/tests/baselines/reference/tsxElementResolution6.errors.txt b/tests/baselines/reference/tsxElementResolution6.errors.txt new file mode 100644 index 00000000000..1336cc6df0c --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxElementResolution6.tsx(8,1): error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxElementResolution6.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + var div: any; + // Still an error +
; + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution6.js b/tests/baselines/reference/tsxElementResolution6.js new file mode 100644 index 00000000000..1b6d174fea8 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution6.js @@ -0,0 +1,15 @@ +//// [tsxElementResolution6.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +var div: any; +// Still an error +
; + + +//// [tsxElementResolution6.jsx] +var div; +// Still an error +
; diff --git a/tests/baselines/reference/tsxElementResolution7.errors.txt b/tests/baselines/reference/tsxElementResolution7.errors.txt new file mode 100644 index 00000000000..b8549e19535 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution7.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxElementResolution7.tsx(12,5): error TS2339: Property 'other' does not exist on type 'typeof my'. +tests/cases/conformance/jsx/tsxElementResolution7.tsx(19,11): error TS2339: Property 'non' does not exist on type 'typeof my'. + + +==== tests/cases/conformance/jsx/tsxElementResolution7.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + module my { + export var div: any; + } + // OK + ; + // Error + ; + ~~~~~ +!!! error TS2339: Property 'other' does not exist on type 'typeof my'. + + module q { + import mine = my; + // OK + ; + // Error + ; + ~~~ +!!! error TS2339: Property 'non' does not exist on type 'typeof my'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution7.js b/tests/baselines/reference/tsxElementResolution7.js new file mode 100644 index 00000000000..7df44b052a2 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution7.js @@ -0,0 +1,39 @@ +//// [tsxElementResolution7.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module my { + export var div: any; +} +// OK +; +// Error +; + +module q { + import mine = my; + // OK + ; + // Error + ; +} + + +//// [tsxElementResolution7.jsx] +var my; +(function (my) { +})(my || (my = {})); +// OK +; +// Error +; +var q; +(function (q) { + var mine = my; + // OK + ; + // Error + ; +})(q || (q = {})); diff --git a/tests/baselines/reference/tsxElementResolution8.errors.txt b/tests/baselines/reference/tsxElementResolution8.errors.txt new file mode 100644 index 00000000000..5710c4e177d --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution8.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element type 'Div' does not have any construct or call signatures. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(16,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(29,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. + + +==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (4 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + // Error + var Div = 3; +
; + ~~~ +!!! error TS2604: JSX element type 'Div' does not have any construct or call signatures. + + // OK + function Fact(): any { return null; } + + + // Error + function Fnum(): number{ return 42; } + + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj1 { + new(): {}; + (): number; + } + var Obj1: Obj1; + ; // OK, prefer construct signatures + + interface Obj2 { + (): number; + } + var Obj2: Obj2; + ; // Error + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj3 { + } + var Obj3: Obj3; + ; // Error + ~~~~ +!!! error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution8.js b/tests/baselines/reference/tsxElementResolution8.js new file mode 100644 index 00000000000..4217761c402 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution8.js @@ -0,0 +1,53 @@ +//// [tsxElementResolution8.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +// Error +var Div = 3; +
; + +// OK +function Fact(): any { return null; } + + +// Error +function Fnum(): number{ return 42; } + + +interface Obj1 { + new(): {}; + (): number; +} +var Obj1: Obj1; +; // OK, prefer construct signatures + +interface Obj2 { + (): number; +} +var Obj2: Obj2; +; // Error + +interface Obj3 { +} +var Obj3: Obj3; +; // Error + + +//// [tsxElementResolution8.jsx] +// Error +var Div = 3; +
; +// OK +function Fact() { return null; } +; +// Error +function Fnum() { return 42; } +; +var Obj1; +; // OK, prefer construct signatures +var Obj2; +; // Error +var Obj3; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution9.errors.txt b/tests/baselines/reference/tsxElementResolution9.errors.txt new file mode 100644 index 00000000000..f4412719b33 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/jsx/tsxElementResolution9.tsx(11,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution9.tsx(18,2): error TS2601: The return type of a JSX element constructor must return an object type. + + +==== tests/cases/conformance/jsx/tsxElementResolution9.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; + } + var Obj1: Obj1; + ; // Error, return type is not an object type + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; + } + var Obj2: Obj2; + ; // Error, return type is not an object type + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; + } + var Obj3: Obj3; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution9.js b/tests/baselines/reference/tsxElementResolution9.js new file mode 100644 index 00000000000..c897a51eaeb --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.js @@ -0,0 +1,35 @@ +//// [tsxElementResolution9.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; +} +var Obj1: Obj1; +; // Error, return type is not an object type + +interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; +} +var Obj2: Obj2; +; // Error, return type is not an object type + +interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; +} +var Obj3: Obj3; +; // OK + + +//// [tsxElementResolution9.jsx] +var Obj1; +; // Error, return type is not an object type +var Obj2; +; // Error, return type is not an object type +var Obj3; +; // OK diff --git a/tests/baselines/reference/tsxEmit1.js b/tests/baselines/reference/tsxEmit1.js new file mode 100644 index 00000000000..baa75526dd7 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.js @@ -0,0 +1,75 @@ +//// [tsxEmit1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; + + +//// [tsxEmit1.jsx] +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 =
{function () { return _this; }}
; + var rewrites2 =
{[p].concat(p, [p])}
; + var rewrites3 =
{{ p: p }}
; + var rewrites4 =
; + var rewrites5 =
; + var rewrites6 =
; + }; + return SomeClass; +})(); +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols new file mode 100644 index 00000000000..284f6cd9ce7 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -0,0 +1,144 @@ +=== tests/cases/conformance/jsx/tsxEmit1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit1.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxEmit1.tsx, 3, 3)) + } +} + +var p; +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +var selfClosed1 =
; +>selfClosed1 : Symbol(selfClosed1, Decl(tsxEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var selfClosed2 =
; +>selfClosed2 : Symbol(selfClosed2, Decl(tsxEmit1.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed3 =
; +>selfClosed3 : Symbol(selfClosed3, Decl(tsxEmit1.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed4 =
; +>selfClosed4 : Symbol(selfClosed4, Decl(tsxEmit1.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed5 =
; +>selfClosed5 : Symbol(selfClosed5, Decl(tsxEmit1.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed6 =
; +>selfClosed6 : Symbol(selfClosed6, Decl(tsxEmit1.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed7 =
; +>selfClosed7 : Symbol(selfClosed7, Decl(tsxEmit1.tsx, 14, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var openClosed1 =
; +>openClosed1 : Symbol(openClosed1, Decl(tsxEmit1.tsx, 16, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var openClosed2 =
foo
; +>openClosed2 : Symbol(openClosed2, Decl(tsxEmit1.tsx, 17, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed3 =
{p}
; +>openClosed3 : Symbol(openClosed3, Decl(tsxEmit1.tsx, 18, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed4 =
{p < p}
; +>openClosed4 : Symbol(openClosed4, Decl(tsxEmit1.tsx, 19, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +var openClosed5 =
{p > p}
; +>openClosed5 : Symbol(openClosed5, Decl(tsxEmit1.tsx, 20, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + f() { +>f : Symbol(f, Decl(tsxEmit1.tsx, 22, 17)) + + var rewrites1 =
{() => this}
; +>rewrites1 : Symbol(rewrites1, Decl(tsxEmit1.tsx, 24, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : Symbol(rewrites2, Decl(tsxEmit1.tsx, 25, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + + var rewrites3 =
{{p}}
; +>rewrites3 : Symbol(rewrites3, Decl(tsxEmit1.tsx, 26, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 26, 25)) + + var rewrites4 =
this}>
; +>rewrites4 : Symbol(rewrites4, Decl(tsxEmit1.tsx, 28, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + var rewrites5 =
; +>rewrites5 : Symbol(rewrites5, Decl(tsxEmit1.tsx, 29, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + + var rewrites6 =
; +>rewrites6 : Symbol(rewrites6, Decl(tsxEmit1.tsx, 30, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 30, 27)) + } +} + +var whitespace1 =
; +>whitespace1 : Symbol(whitespace1, Decl(tsxEmit1.tsx, 34, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var whitespace2 =
{p}
; +>whitespace2 : Symbol(whitespace2, Decl(tsxEmit1.tsx, 35, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var whitespace3 =
+>whitespace3 : Symbol(whitespace3, Decl(tsxEmit1.tsx, 36, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + + {p} +
; + diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types new file mode 100644 index 00000000000..667ec113337 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.types @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/tsxEmit1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p; +>p : any + +var selfClosed1 =
; +>selfClosed1 : JSX.Element +>
: JSX.Element +>div : any + +var selfClosed2 =
; +>selfClosed2 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed3 =
; +>selfClosed3 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed4 =
; +>selfClosed4 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed5 =
; +>selfClosed5 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed6 =
; +>selfClosed6 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed7 =
; +>selfClosed7 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>p : any +>y : any + +var openClosed1 =
; +>openClosed1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var openClosed2 =
foo
; +>openClosed2 : JSX.Element +>
foo
: JSX.Element +>div : any +>n : any +>div : any + +var openClosed3 =
{p}
; +>openClosed3 : JSX.Element +>
{p}
: JSX.Element +>div : any +>n : any +>p : any +>div : any + +var openClosed4 =
{p < p}
; +>openClosed4 : JSX.Element +>
{p < p}
: JSX.Element +>div : any +>n : any +>p < p : boolean +>p : any +>p : any +>div : any + +var openClosed5 =
{p > p}
; +>openClosed5 : JSX.Element +>
{p > p}
: JSX.Element +>div : any +>n : any +>p > p : boolean +>p : any +>p : any +>div : any + +class SomeClass { +>SomeClass : SomeClass + + f() { +>f : () => void + + var rewrites1 =
{() => this}
; +>rewrites1 : JSX.Element +>
{() => this}
: JSX.Element +>div : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : JSX.Element +>
{[p, ...p, p]}
: JSX.Element +>div : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites3 =
{{p}}
; +>rewrites3 : JSX.Element +>
{{p}}
: JSX.Element +>div : any +>{p} : { p: any; } +>p : any +>div : any + + var rewrites4 =
this}>
; +>rewrites4 : JSX.Element +>
this}>
: JSX.Element +>div : any +>a : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites5 =
; +>rewrites5 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites6 =
; +>rewrites6 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>{p} : { p: any; } +>p : any +>div : any + } +} + +var whitespace1 =
; +>whitespace1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var whitespace2 =
{p}
; +>whitespace2 : JSX.Element +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +var whitespace3 =
+>whitespace3 : JSX.Element +>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + diff --git a/tests/baselines/reference/tsxEmit2.js b/tests/baselines/reference/tsxEmit2.js new file mode 100644 index 00000000000..1101df49a1c --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.js @@ -0,0 +1,23 @@ +//// [tsxEmit2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; + + +//// [tsxEmit2.jsx] +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols new file mode 100644 index 00000000000..28f6a9f5026 --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxEmit2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxEmit2.tsx, 3, 3)) + } +} + +var p1, p2, p3; +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) + +var spreads1 =
{p2}
; +>spreads1 : Symbol(spreads1, Decl(tsxEmit2.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + +var spreads2 =
{p2}
; +>spreads2 : Symbol(spreads2, Decl(tsxEmit2.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + +var spreads3 =
{p2}
; +>spreads3 : Symbol(spreads3, Decl(tsxEmit2.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads4 =
{p2}
; +>spreads4 : Symbol(spreads4, Decl(tsxEmit2.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads5 =
{p2}
; +>spreads5 : Symbol(spreads5, Decl(tsxEmit2.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxEmit2.types b/tests/baselines/reference/tsxEmit2.types new file mode 100644 index 00000000000..f5633b739e3 --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsx/tsxEmit2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p1, p2, p3; +>p1 : any +>p2 : any +>p3 : any + +var spreads1 =
{p2}
; +>spreads1 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads2 =
{p2}
; +>spreads2 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads3 =
{p2}
; +>spreads3 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p3 : any +>p1 : any +>p2 : any +>div : any + +var spreads4 =
{p2}
; +>spreads4 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>x : any +>p3 : any +>p2 : any +>div : any + +var spreads5 =
{p2}
; +>spreads5 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p2 : any +>p1 : any +>y : any +>p3 : any +>p2 : any +>div : any + diff --git a/tests/baselines/reference/tsxEmit3.js b/tests/baselines/reference/tsxEmit3.js new file mode 100644 index 00000000000..beae73e2bf1 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.js @@ -0,0 +1,84 @@ +//// [tsxEmit3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module M { + export class Foo { constructor() { } } + export module S { + export class Bar { } + + // Emit Foo + // Foo, ; + } +} + +module M { + // Emit M.Foo + Foo, ; + + export module S { + // Emit M.Foo + Foo, ; + + // Emit S.Bar + Bar, ; + } + +} + +module M { + // Emit M.S.Bar + S.Bar, ; +} + +module M { + var M = 100; + // Emit M_1.Foo + Foo, ; +} + + +//// [tsxEmit3.jsx] +var M; +(function (M) { + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + M.Foo = Foo; + var S; + (function (S) { + var Bar = (function () { + function Bar() { + } + return Bar; + })(); + S.Bar = Bar; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.Foo + M.Foo, ; + var S; + (function (S) { + // Emit M.Foo + M.Foo, ; + // Emit S.Bar + S.Bar, ; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.S.Bar + M.S.Bar, ; +})(M || (M = {})); +var M; +(function (M_1) { + var M = 100; + // Emit M_1.Foo + M_1.Foo, ; +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxEmit3.symbols b/tests/baselines/reference/tsxEmit3.symbols new file mode 100644 index 00000000000..4ceed0b9b1e --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.symbols @@ -0,0 +1,75 @@ +=== tests/cases/conformance/jsx/tsxEmit3.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit3.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit3.tsx, 0, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit3.tsx, 1, 22)) +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + export class Foo { constructor() { } } +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + export module S { +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) + + export class Bar { } +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) + + // Emit Foo + // Foo, ; + } +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + // Emit M.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + export module S { +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) + + // Emit M.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + // Emit S.Bar + Bar, ; +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) + } + +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + // Emit M.S.Bar + S.Bar, ; +>S.Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + var M = 100; +>M : Symbol(M, Decl(tsxEmit3.tsx, 35, 4)) + + // Emit M_1.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +} + diff --git a/tests/baselines/reference/tsxEmit3.types b/tests/baselines/reference/tsxEmit3.types new file mode 100644 index 00000000000..4bb92d9aea5 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.types @@ -0,0 +1,87 @@ +=== tests/cases/conformance/jsx/tsxEmit3.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +module M { +>M : typeof M + + export class Foo { constructor() { } } +>Foo : Foo + + export module S { +>S : typeof S + + export class Bar { } +>Bar : Bar + + // Emit Foo + // Foo, ; + } +} + +module M { +>M : typeof M + + // Emit M.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo + + export module S { +>S : typeof S + + // Emit M.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo + + // Emit S.Bar + Bar, ; +>Bar, : JSX.Element +>Bar : typeof Bar +> : JSX.Element +>Bar : typeof Bar + } + +} + +module M { +>M : typeof M + + // Emit M.S.Bar + S.Bar, ; +>S.Bar, : JSX.Element +>S.Bar : typeof S.Bar +>S : typeof S +>Bar : typeof S.Bar +> : JSX.Element +>S : any +>Bar : any +} + +module M { +>M : typeof M + + var M = 100; +>M : number +>100 : number + + // Emit M_1.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo +} + diff --git a/tests/baselines/reference/tsxErrorRecovery1.errors.txt b/tests/baselines/reference/tsxErrorRecovery1.errors.txt new file mode 100644 index 00000000000..dc4f4d51afe --- /dev/null +++ b/tests/baselines/reference/tsxErrorRecovery1.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(5,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/jsx/tsxErrorRecovery1.tsx (1 errors) ==== + + declare namespace JSX { interface Element { } } + + function foo() { + var x =
{
+ ~~ +!!! error TS1109: Expression expected. + } + // Shouldn't see any errors down here + var y = { a: 1 }; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxErrorRecovery1.js b/tests/baselines/reference/tsxErrorRecovery1.js new file mode 100644 index 00000000000..8d20951f6ed --- /dev/null +++ b/tests/baselines/reference/tsxErrorRecovery1.js @@ -0,0 +1,17 @@ +//// [tsxErrorRecovery1.tsx] + +declare namespace JSX { interface Element { } } + +function foo() { + var x =
{
+} +// Shouldn't see any errors down here +var y = { a: 1 }; + + +//// [tsxErrorRecovery1.jsx] +function foo() { + var x =
{}
; +} +// Shouldn't see any errors down here +var y = { a: 1 }; diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js new file mode 100644 index 00000000000..3e486eacef8 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +// Should see var button_1 = require('./button') here +import { Button } from './button'; + +export class App extends React.Component { + + render() { + return ; + } + +} + +//// [button.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Button = (function (_super) { + __extends(Button, _super); + function Button() { + _super.apply(this, arguments); + } + Button.prototype.render = function () { + return ; + }; + return Button; +})(React.Component); +exports.Button = Button; +//// [app.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +// Should see var button_1 = require('./button') here +var button_1 = require('./button'); +var App = (function (_super) { + __extends(App, _super); + function App() { + _super.apply(this, arguments); + } + App.prototype.render = function () { + return ; + }; + return App; +})(React.Component); +exports.App = App; diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.symbols b/tests/baselines/reference/tsxExternalModuleEmit1.symbols new file mode 100644 index 00000000000..5e8eb2fed4e --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Symbol(Component, Decl(react.d.ts, 1, 24)) +>T : Symbol(T, Decl(react.d.ts, 2, 17)) +>U : Symbol(U, Decl(react.d.ts, 2, 19)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : Symbol(React, Decl(app.tsx, 0, 6)) + +// Should see var button_1 = require('./button') here +import { Button } from './button'; +>Button : Symbol(Button, Decl(app.tsx, 3, 8)) + +export class App extends React.Component { +>App : Symbol(App, Decl(app.tsx, 3, 34)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) +>React : Symbol(React, Decl(app.tsx, 0, 6)) +>Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) + + render() { +>render : Symbol(render, Decl(app.tsx, 5, 52)) + + return ; + } + +} diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.types b/tests/baselines/reference/tsxExternalModuleEmit1.types new file mode 100644 index 00000000000..7e28c35dd13 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Component +>T : T +>U : U +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : typeof React + +// Should see var button_1 = require('./button') here +import { Button } from './button'; +>Button : typeof Button + +export class App extends React.Component { +>App : App +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component + + render() { +>render : () => any + + return ; +> : any +>button : any +>button : any + } + +} diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js new file mode 100644 index 00000000000..f493347ca9c --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js @@ -0,0 +1,46 @@ +//// [tsxGenericArrowFunctionParsing.tsx] +declare module JSX { + interface Element { isElement; } +} + +var T, T1, T2; + +// This is an element +var x1 = () => {}; +x1.isElement; + +// This is a generic function +var x2 = () => {}; +x2(); + +// This is a generic function +var x3 = () => {}; +x3(); + +// This is an element +var x4 = () => {}; +x4.isElement; + +// This is an element +var x5 = () => {}; +x5.isElement; + + + +//// [tsxGenericArrowFunctionParsing.jsx] +var T, T1, T2; +// This is an element +var x1 = () => ; +x1.isElement; +// This is a generic function +var x2 = function () { }; +x2(); +// This is a generic function +var x3 = function () { }; +x3(); +// This is an element +var x4 = () => ; +x4.isElement; +// This is an element +var x5 = () => ; +x5.isElement; diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols new file mode 100644 index 00000000000..8bd68b2e8e7 --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxGenericArrowFunctionParsing.tsx, 0, 0)) + + interface Element { isElement; } +>Element : Symbol(Element, Decl(tsxGenericArrowFunctionParsing.tsx, 0, 20)) +>isElement : Symbol(isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +} + +var T, T1, T2; +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>T1 : Symbol(T1, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 6)) +>T2 : Symbol(T2, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 10)) + +// This is an element +var x1 = () => {}; +>x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) + +x1.isElement; +>x1.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + +// This is a generic function +var x2 = () => {}; +>x2 : Symbol(x2, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 10)) + +x2(); +>x2 : Symbol(x2, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 3)) + +// This is a generic function +var x3 = () => {}; +>x3 : Symbol(x3, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 10)) +>T1 : Symbol(T1, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 12)) + +x3(); +>x3 : Symbol(x3, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 3)) + +// This is an element +var x4 = () => {}; +>x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>extends : Symbol(unknown) + +x4.isElement; +>x4.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + +// This is an element +var x5 = () => {}; +>x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>extends : Symbol(unknown) + +x5.isElement; +>x5.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + + diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types new file mode 100644 index 00000000000..a7d98d35b64 --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types @@ -0,0 +1,75 @@ +=== tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx === +declare module JSX { +>JSX : any + + interface Element { isElement; } +>Element : Element +>isElement : any +} + +var T, T1, T2; +>T : any +>T1 : any +>T2 : any + +// This is an element +var x1 = () => {}; +>x1 : JSX.Element +>() => {} : JSX.Element +>T : any +>T : any + +x1.isElement; +>x1.isElement : any +>x1 : JSX.Element +>isElement : any + +// This is a generic function +var x2 = () => {}; +>x2 : () => void +>() => {} : () => void +>T : T + +x2(); +>x2() : void +>x2 : () => void + +// This is a generic function +var x3 = () => {}; +>x3 : () => void +>() => {} : () => void +>T : T +>T1 : T1 + +x3(); +>x3() : void +>x3 : () => void + +// This is an element +var x4 = () => {}; +>x4 : JSX.Element +>() => {} : JSX.Element +>T : any +>extends : any +>true : boolean +>T : any + +x4.isElement; +>x4.isElement : any +>x4 : JSX.Element +>isElement : any + +// This is an element +var x5 = () => {}; +>x5 : JSX.Element +>() => {} : JSX.Element +>T : any +>extends : any +>T : any + +x5.isElement; +>x5.isElement : any +>x5 : JSX.Element +>isElement : any + + diff --git a/tests/baselines/reference/tsxInArrowFunction.js b/tests/baselines/reference/tsxInArrowFunction.js new file mode 100644 index 00000000000..ba4a0dd1d14 --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.js @@ -0,0 +1,34 @@ +//// [tsxInArrowFunction.tsx] + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + } + } +} + + +// didn't work +
{() =>
}
; + +// didn't work +
{x =>
}
; + +// worked +
{() => (
)}
; + +// worked (!) +
{() =>
}
; + + +//// [tsxInArrowFunction.jsx] +// didn't work +
{function () { return
; }}
; +// didn't work +
{function (x) { return
; }}
; +// worked +
{function () { return (
); }}
; +// worked (!) +
{function () { return
; }}
; diff --git a/tests/baselines/reference/tsxInArrowFunction.symbols b/tests/baselines/reference/tsxInArrowFunction.symbols new file mode 100644 index 00000000000..814f2577bf0 --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/jsx/tsxInArrowFunction.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxInArrowFunction.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxInArrowFunction.tsx, 1, 23)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxInArrowFunction.tsx, 2, 25)) + + div: { +>div : Symbol(div, Decl(tsxInArrowFunction.tsx, 3, 33)) + + text?: string; +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + } + } +} + + +// didn't work +
{() =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// didn't work +
{x =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>x : Symbol(x, Decl(tsxInArrowFunction.tsx, 15, 6)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// worked +
{() => (
)}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// worked (!) +
{() =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + diff --git a/tests/baselines/reference/tsxInArrowFunction.types b/tests/baselines/reference/tsxInArrowFunction.types new file mode 100644 index 00000000000..e4b2aeb50fe --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsx/tsxInArrowFunction.tsx === + +declare namespace JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + div: { +>div : { text?: string; } + + text?: string; +>text : string + } + } +} + + +// didn't work +
{() =>
}
; +>
{() =>
}
: JSX.Element +>div : any +>() =>
: () => JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any + +// didn't work +
{x =>
}
; +>
{x =>
}
: JSX.Element +>div : any +>x =>
: (x: any) => JSX.Element +>x : any +>
: JSX.Element +>div : any +>text : any +>div : any + +// worked +
{() => (
)}
; +>
{() => (
)}
: JSX.Element +>div : any +>() => (
) : () => JSX.Element +>(
) : JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any + +// worked (!) +
{() =>
}
; +>
{() =>
}
: JSX.Element +>div : any +>() =>
: () => JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxNoJsx.js b/tests/baselines/reference/tsxNoJsx.js new file mode 100644 index 00000000000..37663adf2a7 --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.js @@ -0,0 +1,7 @@ +//// [tsxNoJsx.tsx] + +; + + +//// [tsxNoJsx.jsx] +; diff --git a/tests/baselines/reference/tsxNoJsx.symbols b/tests/baselines/reference/tsxNoJsx.symbols new file mode 100644 index 00000000000..6744c2edb10 --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/jsx/tsxNoJsx.tsx === + +No type information for this code.; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/tsxNoJsx.types b/tests/baselines/reference/tsxNoJsx.types new file mode 100644 index 00000000000..52e6769795e --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/jsx/tsxNoJsx.tsx === + +; +> : any +>nope : any + diff --git a/tests/baselines/reference/tsxOpeningClosingNames.js b/tests/baselines/reference/tsxOpeningClosingNames.js new file mode 100644 index 00000000000..80adad0f406 --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.js @@ -0,0 +1,14 @@ +//// [tsxOpeningClosingNames.tsx] +declare module JSX { + interface Element { } +} + +declare module A.B.C { + var D: any; +} + +foo + + +//// [tsxOpeningClosingNames.jsx] +foo; diff --git a/tests/baselines/reference/tsxOpeningClosingNames.symbols b/tests/baselines/reference/tsxOpeningClosingNames.symbols new file mode 100644 index 00000000000..3ff2a3ff68d --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxOpeningClosingNames.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxOpeningClosingNames.tsx, 0, 20)) +} + +declare module A.B.C { +>A : Symbol(A, Decl(tsxOpeningClosingNames.tsx, 2, 1)) +>B : Symbol(B, Decl(tsxOpeningClosingNames.tsx, 4, 17)) +>C : Symbol(C, Decl(tsxOpeningClosingNames.tsx, 4, 19)) + + var D: any; +>D : Symbol(D, Decl(tsxOpeningClosingNames.tsx, 5, 5)) +} + +foo +>D : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxOpeningClosingNames.types b/tests/baselines/reference/tsxOpeningClosingNames.types new file mode 100644 index 00000000000..b02564ae104 --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +declare module A.B.C { +>A : typeof A +>B : typeof B +>C : typeof C + + var D: any; +>D : any +} + +foo +>foo : JSX.Element +>A : any +>B : any +>C : any +>D : any +>A : any +>B : any +>C : any +>D : any + diff --git a/tests/baselines/reference/tsxParseTests1.js b/tests/baselines/reference/tsxParseTests1.js new file mode 100644 index 00000000000..7ab98cab314 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.js @@ -0,0 +1,11 @@ +//// [tsxParseTests1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; + + +//// [tsxParseTests1.jsx] +var x =
; diff --git a/tests/baselines/reference/tsxParseTests1.symbols b/tests/baselines/reference/tsxParseTests1.symbols new file mode 100644 index 00000000000..dbe11dbcbba --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxParseTests1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxParseTests1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxParseTests1.tsx, 0, 20)) + + interface IntrinsicElements { div; span; } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxParseTests1.tsx, 1, 22)) +>div : Symbol(div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(span, Decl(tsxParseTests1.tsx, 2, 35)) +} + +var x =
; +>x : Symbol(x, Decl(tsxParseTests1.tsx, 5, 3)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(tsxParseTests1.tsx, 2, 35)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxParseTests1.types b/tests/baselines/reference/tsxParseTests1.types new file mode 100644 index 00000000000..78e49a227e2 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxParseTests1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { div; span; } +>IntrinsicElements : IntrinsicElements +>div : any +>span : any +} + +var x =
; +>x : JSX.Element +>
: JSX.Element +>div : any +>
: JSX.Element +>div : any +>
: JSX.Element +>span : any +>
: JSX.Element +>div : any +>div : any +>span : any +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js new file mode 100644 index 00000000000..b6c5fd96183 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -0,0 +1,73 @@ +//// [tsxReactEmit1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; + + +//// [tsxReactEmit1.js] +var p; +var selfClosed1 = React.createElement("div", null); +var selfClosed2 = React.createElement("div", {x: "1"}); +var selfClosed3 = React.createElement("div", {x: '1'}); +var selfClosed4 = React.createElement("div", {x: "1", y: '0'}); +var selfClosed5 = React.createElement("div", {x: 0, y: '0'}); +var selfClosed6 = React.createElement("div", {x: "1", y: '0'}); +var selfClosed7 = React.createElement("div", {x: p, y: 'p', b: true}); +var openClosed1 = React.createElement("div", null); +var openClosed2 = React.createElement("div", {n: 'm'}, "foo"); +var openClosed3 = React.createElement("div", {n: 'm'}, p); +var openClosed4 = React.createElement("div", {n: 'm'}, p < p); +var openClosed5 = React.createElement("div", {n: 'm', b: true}, p > p); +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 = React.createElement("div", null, function () { return _this; }); + var rewrites2 = React.createElement("div", null, [p].concat(p, [p])); + var rewrites3 = React.createElement("div", null, { p: p }); + var rewrites4 = React.createElement("div", {a: function () { return _this; }}); + var rewrites5 = React.createElement("div", {a: [p].concat(p, [p])}); + var rewrites6 = React.createElement("div", {a: { p: p }}); + }; + return SomeClass; +})(); +var whitespace1 = React.createElement("div", null); +var whitespace2 = React.createElement("div", null, p); +var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols new file mode 100644 index 00000000000..60fa5e70b0a --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -0,0 +1,146 @@ +=== tests/cases/conformance/jsx/tsxReactEmit1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmit1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmit1.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmit1.tsx, 3, 3)) + } +} + +var p; +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + +var selfClosed1 =
; +>selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var selfClosed2 =
; +>selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed3 =
; +>selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed4 =
; +>selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed5 =
; +>selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed6 =
; +>selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed7 =
; +>selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 14, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) +>b : Symbol(unknown) + +var openClosed1 =
; +>openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 16, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var openClosed2 =
foo
; +>openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 17, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed3 =
{p}
; +>openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 18, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed4 =
{p < p}
; +>openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 19, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + +var openClosed5 =
{p > p}
; +>openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 20, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>b : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) + + f() { +>f : Symbol(f, Decl(tsxReactEmit1.tsx, 22, 17)) + + var rewrites1 =
{() => this}
; +>rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 24, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 25, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + + var rewrites3 =
{{p}}
; +>rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 26, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 26, 25)) + + var rewrites4 =
this}>
; +>rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 28, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) + + var rewrites5 =
; +>rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 29, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) + + var rewrites6 =
; +>rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 30, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 30, 27)) + } +} + +var whitespace1 =
; +>whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 34, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var whitespace2 =
{p}
; +>whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 35, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var whitespace3 =
+>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 36, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + + {p} +
; + diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types new file mode 100644 index 00000000000..d23cad4560a --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -0,0 +1,196 @@ +=== tests/cases/conformance/jsx/tsxReactEmit1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p; +>p : any + +var selfClosed1 =
; +>selfClosed1 : JSX.Element +>
: JSX.Element +>div : any + +var selfClosed2 =
; +>selfClosed2 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed3 =
; +>selfClosed3 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed4 =
; +>selfClosed4 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed5 =
; +>selfClosed5 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed6 =
; +>selfClosed6 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed7 =
; +>selfClosed7 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>p : any +>y : any +>b : any + +var openClosed1 =
; +>openClosed1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var openClosed2 =
foo
; +>openClosed2 : JSX.Element +>
foo
: JSX.Element +>div : any +>n : any +>div : any + +var openClosed3 =
{p}
; +>openClosed3 : JSX.Element +>
{p}
: JSX.Element +>div : any +>n : any +>p : any +>div : any + +var openClosed4 =
{p < p}
; +>openClosed4 : JSX.Element +>
{p < p}
: JSX.Element +>div : any +>n : any +>p < p : boolean +>p : any +>p : any +>div : any + +var openClosed5 =
{p > p}
; +>openClosed5 : JSX.Element +>
{p > p}
: JSX.Element +>div : any +>n : any +>b : any +>p > p : boolean +>p : any +>p : any +>div : any + +class SomeClass { +>SomeClass : SomeClass + + f() { +>f : () => void + + var rewrites1 =
{() => this}
; +>rewrites1 : JSX.Element +>
{() => this}
: JSX.Element +>div : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : JSX.Element +>
{[p, ...p, p]}
: JSX.Element +>div : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites3 =
{{p}}
; +>rewrites3 : JSX.Element +>
{{p}}
: JSX.Element +>div : any +>{p} : { p: any; } +>p : any +>div : any + + var rewrites4 =
this}>
; +>rewrites4 : JSX.Element +>
this}>
: JSX.Element +>div : any +>a : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites5 =
; +>rewrites5 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites6 =
; +>rewrites6 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>{p} : { p: any; } +>p : any +>div : any + } +} + +var whitespace1 =
; +>whitespace1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var whitespace2 =
{p}
; +>whitespace2 : JSX.Element +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +var whitespace3 =
+>whitespace3 : JSX.Element +>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js new file mode 100644 index 00000000000..f4a12946ed9 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -0,0 +1,23 @@ +//// [tsxReactEmit2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; + + +//// [tsxReactEmit2.js] +var p1, p2, p3; +var spreads1 = React.createElement("div", React.__spread({}, p1), p2); +var spreads2 = React.createElement("div", React.__spread({}, p1), p2); +var spreads3 = React.createElement("div", React.__spread({x: p3}, p1), p2); +var spreads4 = React.createElement("div", React.__spread({}, p1, {x: p3}), p2); +var spreads5 = React.createElement("div", React.__spread({x: p2}, p1, {y: p3}), p2); diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols new file mode 100644 index 00000000000..9607d9330da --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxReactEmit2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmit2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmit2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmit2.tsx, 3, 3)) + } +} + +var p1, p2, p3; +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 7, 7)) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 7, 11)) + +var spreads1 =
{p2}
; +>spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + +var spreads2 =
{p2}
; +>spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + +var spreads3 =
{p2}
; +>spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads4 =
{p2}
; +>spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads5 =
{p2}
; +>spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types new file mode 100644 index 00000000000..9f8d6e494d0 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsx/tsxReactEmit2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p1, p2, p3; +>p1 : any +>p2 : any +>p3 : any + +var spreads1 =
{p2}
; +>spreads1 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads2 =
{p2}
; +>spreads2 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads3 =
{p2}
; +>spreads3 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p3 : any +>p1 : any +>p2 : any +>div : any + +var spreads4 =
{p2}
; +>spreads4 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>x : any +>p3 : any +>p2 : any +>div : any + +var spreads5 =
{p2}
; +>spreads5 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p2 : any +>p1 : any +>y : any +>p3 : any +>p2 : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js new file mode 100644 index 00000000000..d31fec1c550 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -0,0 +1,10 @@ +//// [tsxReactEmit3.tsx] + +declare module JSX { interface Element { } } + +declare var Foo, Bar, baz; + + q s ; + +//// [tsxReactEmit3.js] +React.createElement(Foo, null, React.createElement(Bar, null, "q "), React.createElement(Bar, null), "s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols new file mode 100644 index 00000000000..8ef0ccab241 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsx/tsxReactEmit3.tsx === + +declare module JSX { interface Element { } } +>JSX : Symbol(JSX, Decl(tsxReactEmit3.tsx, 0, 0)) +>Element : Symbol(Element, Decl(tsxReactEmit3.tsx, 1, 20)) + +declare var Foo, Bar, baz; +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 3, 21)) + + q s ; +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) + diff --git a/tests/baselines/reference/tsxReactEmit3.types b/tests/baselines/reference/tsxReactEmit3.types new file mode 100644 index 00000000000..9e5d9fece56 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxReactEmit3.tsx === + +declare module JSX { interface Element { } } +>JSX : any +>Element : Element + +declare var Foo, Bar, baz; +>Foo : any +>Bar : any +>baz : any + + q s ; +> q s : JSX.Element +>Foo : any +> q : JSX.Element +>Bar : any +>Bar : any +> : JSX.Element +>Bar : any +> : JSX.Element +>Bar : any +> : JSX.Element +>Bar : any +>Foo : any + diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt new file mode 100644 index 00000000000..00b7cb8d019 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find name 'blah'. + + +==== tests/cases/conformance/jsx/tsxReactEmit4.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } + } + + var p; + var openClosed1 =
+ + {blah} + ~~~~ +!!! error TS2304: Cannot find name 'blah'. + +
; + + // Should emit React.__spread({}, p, {x: 0}) + var spread1 =
; \ No newline at end of file diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js new file mode 100644 index 00000000000..2254c4dd651 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -0,0 +1,23 @@ +//// [tsxReactEmit4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var openClosed1 =
+ + {blah} + +
; + +// Should emit React.__spread({}, p, {x: 0}) +var spread1 =
; + +//// [tsxReactEmit4.js] +var p; +var openClosed1 = React.createElement("div", null, blah); +// Should emit React.__spread({}, p, {x: 0}) +var spread1 = React.createElement("div", React.__spread({}, p, {x: 0})); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js new file mode 100644 index 00000000000..2f32295c279 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -0,0 +1,75 @@ +//// [tsxReactEmitWhitespace.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +// Emit " " +
; +// Emit " ", p, " " +
{p}
; +// Emit only p +
+ {p} +
; + +// Emit only p +
+ {p} +
; + +// Emit " 3" +
3 +
; + +// Emit " 3 " +
3
; + +// Emit "3" +
+ 3 +
; + +// Emit no args +
+
; + +// Emit "foo" + ' ' + "bar" +
+ + foo + + bar + +
; + + + +//// [tsxReactEmitWhitespace.js] +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT +var p = 0; +// Emit " " +React.createElement("div", null); +// Emit " ", p, " " +React.createElement("div", null, p); +// Emit only p +React.createElement("div", null, p); +// Emit only p +React.createElement("div", null, p); +// Emit " 3" +React.createElement("div", null, "3"); +// Emit " 3 " +React.createElement("div", null, "3 "); +// Emit "3" +React.createElement("div", null, "3"); +// Emit no args +React.createElement("div", null); +// Emit "foo" + ' ' + "bar" +React.createElement("div", null, "foo" + ' ' + "bar"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols new file mode 100644 index 00000000000..afbb6944981 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -0,0 +1,77 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitWhitespace.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitWhitespace.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitWhitespace.tsx, 3, 3)) + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 10, 3)) + +// Emit " " +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit " ", p, " " +
{p}
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit only p +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + {p} +
; + +// Emit only p +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + {p} +
; + +// Emit " 3" +
3 +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +
; + +// Emit " 3 " +
3
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit "3" +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + 3 +
; + +// Emit no args +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +
; + +// Emit "foo" + ' ' + "bar" +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + foo + + bar + +
; + + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types new file mode 100644 index 00000000000..e0e3639fa9b --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -0,0 +1,101 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +>p : number +>0 : number + +// Emit " " +
; +>
: JSX.Element +>div : any +>div : any + +// Emit " ", p, " " +
{p}
; +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +// Emit only p +
+>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + +// Emit only p +
+>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + +// Emit " 3" +
3 +>
3
: JSX.Element +>div : any + +
; +>div : any + +// Emit " 3 " +
3
; +>
3
: JSX.Element +>div : any +>div : any + +// Emit "3" +
+>
3
: JSX.Element +>div : any + + 3 +
; +>div : any + +// Emit no args +
+>
: JSX.Element +>div : any + +
; +>div : any + +// Emit "foo" + ' ' + "bar" +
+>
foo bar
: JSX.Element +>div : any + + foo + + bar + +
; +>div : any + + diff --git a/tests/baselines/reference/tsxTypeErrors.js b/tests/baselines/reference/tsxTypeErrors.js new file mode 100644 index 00000000000..f195a459747 --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.js @@ -0,0 +1,60 @@ +//// [tsxTypeErrors.tsx] + +// A built-in element (OK) +var a1 =
; + +// A built-in element with a mistyped property (error) +var a2 = + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
+ +// Mistyped html name (error) +var e1 = + +// A custom type +class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; + + + +//// [tsxTypeErrors.jsx] +// A built-in element (OK) +var a1 =
; +// A built-in element with a mistyped property (error) +var a2 = ; +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
; +// Mistyped html name (error) +var e1 = ; +// A custom type +var MyClass = (function () { + function MyClass() { + } + return MyClass; +})(); +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols new file mode 100644 index 00000000000..bfe0c568640 --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -0,0 +1,65 @@ +=== tests/cases/conformance/jsx/tsxTypeErrors.tsx === + +// A built-in element (OK) +var a1 =
; +>a1 : Symbol(a1, Decl(tsxTypeErrors.tsx, 2, 3)) +>id : Symbol(unknown) + +// A built-in element with a mistyped property (error) +var a2 = +>a2 : Symbol(a2, Decl(tsxTypeErrors.tsx, 5, 3)) +>srce : Symbol(unknown) + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3)) +>oops : Symbol(oops, Decl(tsxTypeErrors.tsx, 8, 13)) + +var a3 =
+>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3)) +>id : Symbol(unknown) + +// Mistyped html name (error) +var e1 = +>e1 : Symbol(e1, Decl(tsxTypeErrors.tsx, 12, 3)) +>src : Symbol(unknown) + +// A custom type +class MyClass { +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) + + props: { +>props : Symbol(props, Decl(tsxTypeErrors.tsx, 15, 15)) + + pt?: { x: number; y: number; }; +>pt : Symbol(pt, Decl(tsxTypeErrors.tsx, 16, 10)) +>x : Symbol(x, Decl(tsxTypeErrors.tsx, 17, 10)) +>y : Symbol(y, Decl(tsxTypeErrors.tsx, 17, 21)) + + name?: string; +>name : Symbol(name, Decl(tsxTypeErrors.tsx, 17, 35)) + + reqd: boolean; +>reqd : Symbol(reqd, Decl(tsxTypeErrors.tsx, 18, 15)) + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +>b1 : Symbol(b1, Decl(tsxTypeErrors.tsx, 25, 3)) +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) +>reqd : Symbol(unknown) + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; +>b2 : Symbol(b2, Decl(tsxTypeErrors.tsx, 31, 3)) +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) +>pt : Symbol(unknown) +>x : Symbol(x, Decl(tsxTypeErrors.tsx, 31, 23)) +>y : Symbol(y, Decl(tsxTypeErrors.tsx, 31, 28)) + + diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types new file mode 100644 index 00000000000..92c7148b314 --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/jsx/tsxTypeErrors.tsx === + +// A built-in element (OK) +var a1 =
; +>a1 : any +>
: any +>div : any +>id : any + +// A built-in element with a mistyped property (error) +var a2 = +>a2 : any +> : any +>img : any +>srce : any + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +>thing : { oops: number; } +>{ oops: 100 } : { oops: number; } +>oops : number +>100 : number + +var a3 =
+>a3 : any +>
: any +>div : any +>id : any +>thing : any + +// Mistyped html name (error) +var e1 = +>e1 : any +> : any +>imag : any +>src : any + +// A custom type +class MyClass { +>MyClass : MyClass + + props: { +>props : { pt?: { x: number; y: number; }; name?: string; reqd: boolean; } + + pt?: { x: number; y: number; }; +>pt : { x: number; y: number; } +>x : number +>y : number + + name?: string; +>name : string + + reqd: boolean; +>reqd : boolean + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +>b1 : any +> : any +>MyClass : typeof MyClass +>reqd : any +>true : boolean + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; +>b2 : any +> : any +>MyClass : typeof MyClass +>pt : any +>{x: 4, y: 'oops'} : { x: number; y: string; } +>x : number +>4 : number +>y : string +>'oops' : string + + diff --git a/tests/baselines/reference/typeAssertions.js b/tests/baselines/reference/typeAssertions.js index 51ca6a27f0e..3645e61f2ba 100644 --- a/tests/baselines/reference/typeAssertions.js +++ b/tests/baselines/reference/typeAssertions.js @@ -46,8 +46,7 @@ someOther = someOther; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // Function call whose argument is a 1 arg generic function call with explicit type arguments function fn1(t) { } diff --git a/tests/baselines/reference/typeGuardFunction.js b/tests/baselines/reference/typeGuardFunction.js index f6b752c8c04..bff304682af 100644 --- a/tests/baselines/reference/typeGuardFunction.js +++ b/tests/baselines/reference/typeGuardFunction.js @@ -87,8 +87,7 @@ let union3: boolean | B = isA(union2) || union2; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/typeGuardFunction.symbols b/tests/baselines/reference/typeGuardFunction.symbols index c315e721085..13ad30de5c5 100644 --- a/tests/baselines/reference/typeGuardFunction.symbols +++ b/tests/baselines/reference/typeGuardFunction.symbols @@ -25,16 +25,19 @@ class C extends A { declare function isA(p1: any): p1 is A; >isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 13, 21)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 13, 21)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) declare function isB(p1: any): p1 is B; >isB : Symbol(isB, Decl(typeGuardFunction.ts, 13, 39)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 14, 21)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 14, 21)) >B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1)) declare function isC(p1: any): p1 is C; >isC : Symbol(isC, Decl(typeGuardFunction.ts, 14, 39)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 15, 21)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 15, 21)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) declare function retC(): C; @@ -98,6 +101,7 @@ interface I1 { (p1: A): p1 is C; >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 41, 5)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 41, 5)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) } @@ -107,6 +111,7 @@ declare function isC_multipleParams(p1, p2): p1 is C; >isC_multipleParams : Symbol(isC_multipleParams, Decl(typeGuardFunction.ts, 42, 1)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 46, 36)) >p2 : Symbol(p2, Decl(typeGuardFunction.ts, 46, 39)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 46, 36)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) if (isC_multipleParams(a, 0)) { @@ -127,6 +132,7 @@ var obj: { >func1 : Symbol(func1, Decl(typeGuardFunction.ts, 52, 10)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 53, 10)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 53, 10)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) } class D { @@ -136,6 +142,7 @@ class D { >method1 : Symbol(method1, Decl(typeGuardFunction.ts, 55, 9)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 56, 12)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 56, 12)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) return true; @@ -147,6 +154,7 @@ let f1 = (p1: A): p1 is C => false; >f1 : Symbol(f1, Decl(typeGuardFunction.ts, 62, 3)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 62, 10)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 62, 10)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) // Function type @@ -155,6 +163,7 @@ declare function f2(p1: (p1: A) => p1 is C); >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 65, 20)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 65, 25)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 65, 25)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) // Function expressions @@ -162,6 +171,7 @@ f2(function(p1: A): p1 is C { >f2 : Symbol(f2, Decl(typeGuardFunction.ts, 62, 35)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 68, 12)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) +>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 68, 12)) >C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1)) return true; @@ -182,6 +192,7 @@ declare function acceptingTypeGuardFunction(p1: (item) => item is A); >acceptingTypeGuardFunction : Symbol(acceptingTypeGuardFunction, Decl(typeGuardFunction.ts, 74, 25)) >p1 : Symbol(p1, Decl(typeGuardFunction.ts, 77, 44)) >item : Symbol(item, Decl(typeGuardFunction.ts, 77, 49)) +>item : Symbol(item, Decl(typeGuardFunction.ts, 77, 49)) >A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0)) acceptingTypeGuardFunction(isA); diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 1542bbe0fee..499a51035f2 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,42 +1,43 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(22,33): error TS2304: Cannot find name 'x'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(26,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(27,5): error TS1131: Property or signature expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(28,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,38): error TS1225: Cannot find parameter 'x'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(34,51): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(26,33): error TS1225: Cannot find parameter 'x'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,10): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(31,5): error TS1131: Property or signature expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(32,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(34,38): error TS1225: Cannot find parameter 'x'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(38,51): error TS2322: Type 'B' is not assignable to type 'A'. Property 'propA' is missing in type 'B'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(38,56): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(42,56): error TS2322: Type 'T[]' is not assignable to type 'string'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(56,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(61,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(66,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(71,46): error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(42,56): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(46,56): error TS2322: Type 'T[]' is not assignable to type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(60,7): error TS2339: Property 'propB' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(65,7): error TS2339: Property 'propB' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(70,7): error TS2339: Property 'propB' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'. Type predicate 'p1 is C' is not assignable to 'p1 is B'. Type 'C' is not assignable to type 'B'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. Signature '(p1: any, p2: any): boolean' must have a type predicate. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(81,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. Type predicate 'p2 is A' is not assignable to 'p1 is A'. Parameter 'p2' is not in the same position as parameter 'p1'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(87,1): error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(92,9): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(93,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(94,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(100,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(101,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(103,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(106,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,16): error TS2408: Setters cannot return a value. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(112,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,22): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,20): error TS1229: A type predicate cannot reference a rest parameter. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(125,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,9): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(124,20): error TS1229: A type predicate cannot reference a rest parameter. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(129,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (30 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (31 errors) ==== class A { propA: number; @@ -66,6 +67,12 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,39 return true; } + function hasMissingParameter(): x is A { + ~ +!!! error TS1225: Cannot find parameter 'x'. + return true; + } + function hasMissingTypeInTypeGuardType(x): x is { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. @@ -237,4 +244,10 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,39 ~~ !!! error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. return true; + } + + // Should not crash the compiler + var x: A; + if (hasMissingParameter()) { + x.propA; } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardFunctionErrors.js b/tests/baselines/reference/typeGuardFunctionErrors.js index 179a3b80cf0..4923f544345 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.js +++ b/tests/baselines/reference/typeGuardFunctionErrors.js @@ -24,6 +24,10 @@ function hasMissingIsKeyword(): x { return true; } +function hasMissingParameter(): x is A { + return true; +} + function hasMissingTypeInTypeGuardType(x): x is { return true; } @@ -133,14 +137,19 @@ function b6([a, b, p1], p2, p3): p1 is A { function b7({a, b, c: {p1}}, p2, p3): p1 is A { return true; +} + +// Should not crash the compiler +var x: A; +if (hasMissingParameter()) { + x.propA; } //// [typeGuardFunctionErrors.js] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { @@ -168,6 +177,9 @@ function hasTypeGuardTypeInsideTypeGuardType(x) { function hasMissingIsKeyword() { return true; } +function hasMissingParameter() { + return true; +} return true; function hasNonMatchingParameter(y) { return true; @@ -261,3 +273,8 @@ function b7(_a, p2, p3) { var a = _a.a, b = _a.b, p1 = _a.c.p1; return true; } +// Should not crash the compiler +var x; +if (hasMissingParameter()) { + x.propA; +} diff --git a/tests/baselines/reference/typeGuardFunctionGenerics.js b/tests/baselines/reference/typeGuardFunctionGenerics.js index 6704225a0d0..edf5cb97fe4 100644 --- a/tests/baselines/reference/typeGuardFunctionGenerics.js +++ b/tests/baselines/reference/typeGuardFunctionGenerics.js @@ -37,8 +37,7 @@ let test3: B = funE(isB, 1); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var A = (function () { function A() { diff --git a/tests/baselines/reference/typeGuardFunctionGenerics.symbols b/tests/baselines/reference/typeGuardFunctionGenerics.symbols index 0ad8fab2fdb..100d610070d 100644 --- a/tests/baselines/reference/typeGuardFunctionGenerics.symbols +++ b/tests/baselines/reference/typeGuardFunctionGenerics.symbols @@ -25,11 +25,13 @@ class C extends A { declare function isB(p1): p1 is B; >isB : Symbol(isB, Decl(typeGuardFunctionGenerics.ts, 11, 1)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 13, 21)) +>p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 13, 21)) >B : Symbol(B, Decl(typeGuardFunctionGenerics.ts, 3, 1)) declare function isC(p1): p1 is C; >isC : Symbol(isC, Decl(typeGuardFunctionGenerics.ts, 13, 34)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 14, 21)) +>p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 14, 21)) >C : Symbol(C, Decl(typeGuardFunctionGenerics.ts, 7, 1)) declare function retC(x): C; @@ -52,6 +54,7 @@ declare function funB(p1: (p1) => T, p2: any): p2 is T; >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 18, 30)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 18, 22)) >p2 : Symbol(p2, Decl(typeGuardFunctionGenerics.ts, 18, 39)) +>p2 : Symbol(p2, Decl(typeGuardFunctionGenerics.ts, 18, 39)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 18, 22)) declare function funC(p1: (p1) => p1 is T): T; @@ -59,6 +62,7 @@ declare function funC(p1: (p1) => p1 is T): T; >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 19, 22)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 19, 25)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 19, 30)) +>p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 19, 30)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 19, 22)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 19, 22)) @@ -67,8 +71,10 @@ declare function funD(p1: (p1) => p1 is T, p2: any): p2 is T; >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 20, 22)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 20, 25)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 20, 30)) +>p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 20, 30)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 20, 22)) >p2 : Symbol(p2, Decl(typeGuardFunctionGenerics.ts, 20, 45)) +>p2 : Symbol(p2, Decl(typeGuardFunctionGenerics.ts, 20, 45)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 20, 22)) declare function funE(p1: (p1) => p1 is T, p2: U): T; @@ -77,6 +83,7 @@ declare function funE(p1: (p1) => p1 is T, p2: U): T; >U : Symbol(U, Decl(typeGuardFunctionGenerics.ts, 21, 24)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 21, 28)) >p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 21, 33)) +>p1 : Symbol(p1, Decl(typeGuardFunctionGenerics.ts, 21, 33)) >T : Symbol(T, Decl(typeGuardFunctionGenerics.ts, 21, 22)) >p2 : Symbol(p2, Decl(typeGuardFunctionGenerics.ts, 21, 48)) >U : Symbol(U, Decl(typeGuardFunctionGenerics.ts, 21, 24)) diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.js b/tests/baselines/reference/typeGuardOfFormInstanceOf.js index de7e9813a84..cab04365c19 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.js +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.js @@ -39,8 +39,7 @@ var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/typeGuardOfFormIsType.js b/tests/baselines/reference/typeGuardOfFormIsType.js index 65d99319d1e..8400aef59ad 100644 --- a/tests/baselines/reference/typeGuardOfFormIsType.js +++ b/tests/baselines/reference/typeGuardOfFormIsType.js @@ -41,8 +41,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1 var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C1 = (function () { function C1() { diff --git a/tests/baselines/reference/typeGuardOfFormIsType.symbols b/tests/baselines/reference/typeGuardOfFormIsType.symbols index a7bd0f4c165..e7e8965673d 100644 --- a/tests/baselines/reference/typeGuardOfFormIsType.symbols +++ b/tests/baselines/reference/typeGuardOfFormIsType.symbols @@ -31,6 +31,7 @@ var strOrNum: string | number; function isC1(x: any): x is C1 { >isC1 : Symbol(isC1, Decl(typeGuardOfFormIsType.ts, 12, 30)) >x : Symbol(x, Decl(typeGuardOfFormIsType.ts, 14, 14)) +>x : Symbol(x, Decl(typeGuardOfFormIsType.ts, 14, 14)) >C1 : Symbol(C1, Decl(typeGuardOfFormIsType.ts, 0, 0)) return true; @@ -39,6 +40,7 @@ function isC1(x: any): x is C1 { function isC2(x: any): x is C2 { >isC2 : Symbol(isC2, Decl(typeGuardOfFormIsType.ts, 16, 1)) >x : Symbol(x, Decl(typeGuardOfFormIsType.ts, 18, 14)) +>x : Symbol(x, Decl(typeGuardOfFormIsType.ts, 18, 14)) >C2 : Symbol(C2, Decl(typeGuardOfFormIsType.ts, 3, 1)) return true; @@ -47,6 +49,7 @@ function isC2(x: any): x is C2 { function isD1(x: any): x is D1 { >isD1 : Symbol(isD1, Decl(typeGuardOfFormIsType.ts, 20, 1)) >x : Symbol(x, Decl(typeGuardOfFormIsType.ts, 22, 14)) +>x : Symbol(x, Decl(typeGuardOfFormIsType.ts, 22, 14)) >D1 : Symbol(D1, Decl(typeGuardOfFormIsType.ts, 6, 1)) return true; diff --git a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.symbols b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.symbols index 37249ef7659..641d20d95cd 100644 --- a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.symbols +++ b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.symbols @@ -50,6 +50,7 @@ var strOrNum: string | number; function isC1(x: any): x is C1 { >isC1 : Symbol(isC1, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 17, 30)) >x : Symbol(x, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 20, 14)) +>x : Symbol(x, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 20, 14)) >C1 : Symbol(C1, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 0, 0)) return true; @@ -58,6 +59,7 @@ function isC1(x: any): x is C1 { function isC2(x: any): x is C2 { >isC2 : Symbol(isC2, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 22, 1)) >x : Symbol(x, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 24, 14)) +>x : Symbol(x, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 24, 14)) >C2 : Symbol(C2, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 5, 1)) return true; @@ -66,6 +68,7 @@ function isC2(x: any): x is C2 { function isD1(x: any): x is D1 { >isD1 : Symbol(isD1, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 26, 1)) >x : Symbol(x, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 28, 14)) +>x : Symbol(x, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 28, 14)) >D1 : Symbol(D1, Decl(typeGuardOfFormIsTypeOnInterfaces.ts, 10, 1)) return true; diff --git a/tests/baselines/reference/typeMatch2.js b/tests/baselines/reference/typeMatch2.js index 6f05bf684f1..c4550750ca2 100644 --- a/tests/baselines/reference/typeMatch2.js +++ b/tests/baselines/reference/typeMatch2.js @@ -48,8 +48,7 @@ function f4() { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; function f1() { var a = { x: 1, y: 2 }; diff --git a/tests/baselines/reference/typeOfSuperCall.js b/tests/baselines/reference/typeOfSuperCall.js index 5df29d615e4..72cdd7d528e 100644 --- a/tests/baselines/reference/typeOfSuperCall.js +++ b/tests/baselines/reference/typeOfSuperCall.js @@ -12,8 +12,7 @@ class D extends C { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C() { diff --git a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt index 5602bf69f57..dec7f7f2a4a 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2311: A class may only extend another class. +tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'. tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface. ==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ==== class C extends T {} ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'T'. class C2 implements T {} ~ !!! error TS2422: A class may only implement another class or interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseClass.js b/tests/baselines/reference/typeParameterAsBaseClass.js index b00a00abac5..f17db28f657 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.js +++ b/tests/baselines/reference/typeParameterAsBaseClass.js @@ -6,8 +6,7 @@ class C2 implements T {} var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/typeParameterAsBaseType.errors.txt b/tests/baselines/reference/typeParameterAsBaseType.errors.txt index b945dcdd987..835b2369948 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseType.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2311: A class may only extend another class. -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2311: A class may only extend another class. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface. @@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e class C extends T { } ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'T'. class C2 extends U { } ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'U'. interface I extends T { } ~ diff --git a/tests/baselines/reference/typeParameterAsBaseType.js b/tests/baselines/reference/typeParameterAsBaseType.js index 2715c09fa23..de9a0ed2587 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.js +++ b/tests/baselines/reference/typeParameterAsBaseType.js @@ -16,8 +16,7 @@ interface I2 extends U { } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function (_super) { __extends(C, _super); diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.js b/tests/baselines/reference/typeParameterExtendingUnion1.js index c5e8fccf350..3027f119fb9 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.js +++ b/tests/baselines/reference/typeParameterExtendingUnion1.js @@ -16,8 +16,7 @@ function f(a: T) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Animal = (function () { function Animal() { diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.js b/tests/baselines/reference/typeParameterExtendingUnion2.js index e53aeb42f22..55f6d3e07e2 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.js +++ b/tests/baselines/reference/typeParameterExtendingUnion2.js @@ -16,8 +16,7 @@ function f(a: T) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Animal = (function () { function Animal() { diff --git a/tests/baselines/reference/typeValueConflict1.js b/tests/baselines/reference/typeValueConflict1.js index d036d90262f..0a6e92d0d62 100644 --- a/tests/baselines/reference/typeValueConflict1.js +++ b/tests/baselines/reference/typeValueConflict1.js @@ -15,8 +15,7 @@ module M2 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M1; (function (M1) { diff --git a/tests/baselines/reference/typeValueConflict2.js b/tests/baselines/reference/typeValueConflict2.js index c927e70615a..6e925b535a3 100644 --- a/tests/baselines/reference/typeValueConflict2.js +++ b/tests/baselines/reference/typeValueConflict2.js @@ -22,8 +22,7 @@ module M3 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M1; (function (M1) { diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index f4a310ef0fc..6b9842f6c81 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -242,65 +242,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2391, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2391, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2681, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2681, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3261, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3261, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3551, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3551, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3841, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3841, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4131, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4131, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4421, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4421, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4711, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4711, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2971, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2971, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2117, 42), Decl(lib.d.ts, 2407, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2397, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2407, 44), Decl(lib.d.ts, 2697, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2687, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2987, 60), Decl(lib.d.ts, 3277, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3267, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3277, 46), Decl(lib.d.ts, 3567, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3557, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3567, 48), Decl(lib.d.ts, 3857, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3847, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3857, 46), Decl(lib.d.ts, 4147, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4137, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4147, 48), Decl(lib.d.ts, 4437, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4427, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4437, 50), Decl(lib.d.ts, 4727, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4717, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2697, 46), Decl(lib.d.ts, 2987, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2977, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/typeofClass2.js b/tests/baselines/reference/typeofClass2.js index f4401db1549..d16abbda6e5 100644 --- a/tests/baselines/reference/typeofClass2.js +++ b/tests/baselines/reference/typeofClass2.js @@ -25,8 +25,7 @@ var r2: typeof d; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var C = (function () { function C(x) { diff --git a/tests/baselines/reference/typesWithSpecializedCallSignatures.js b/tests/baselines/reference/typesWithSpecializedCallSignatures.js index 4baa9d71194..3de4134789e 100644 --- a/tests/baselines/reference/typesWithSpecializedCallSignatures.js +++ b/tests/baselines/reference/typesWithSpecializedCallSignatures.js @@ -46,8 +46,7 @@ var r3: Base = c.foo('hm'); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/typesWithSpecializedConstructSignatures.js b/tests/baselines/reference/typesWithSpecializedConstructSignatures.js index 8f64b4be3bf..c66c471b3a1 100644 --- a/tests/baselines/reference/typesWithSpecializedConstructSignatures.js +++ b/tests/baselines/reference/typesWithSpecializedConstructSignatures.js @@ -44,8 +44,7 @@ var r3: Base = new a('hm'); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/undeclaredBase.errors.txt b/tests/baselines/reference/undeclaredBase.errors.txt index 5a6d838284c..25d550572d4 100644 --- a/tests/baselines/reference/undeclaredBase.errors.txt +++ b/tests/baselines/reference/undeclaredBase.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/undeclaredBase.ts(1,37): error TS2305: Module 'M' has no exported member 'I'. +tests/cases/compiler/undeclaredBase.ts(1,37): error TS2339: Property 'I' does not exist on type 'typeof M'. ==== tests/cases/compiler/undeclaredBase.ts (1 errors) ==== module M { export class C extends M.I { } } ~ -!!! error TS2305: Module 'M' has no exported member 'I'. +!!! error TS2339: Property 'I' does not exist on type 'typeof M'. \ No newline at end of file diff --git a/tests/baselines/reference/undeclaredBase.js b/tests/baselines/reference/undeclaredBase.js index bb78d5995c3..b1efffc0e24 100644 --- a/tests/baselines/reference/undeclaredBase.js +++ b/tests/baselines/reference/undeclaredBase.js @@ -7,8 +7,7 @@ module M { export class C extends M.I { } } var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var M; (function (M) { diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.js b/tests/baselines/reference/undefinedIsSubtypeOfEverything.js index 49877eb62e0..c89c3f65381 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.js +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.js @@ -126,8 +126,7 @@ class D17 extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base() { diff --git a/tests/baselines/reference/underscoreMapFirst.js b/tests/baselines/reference/underscoreMapFirst.js index c1839fadfdc..4ee69572f1d 100644 --- a/tests/baselines/reference/underscoreMapFirst.js +++ b/tests/baselines/reference/underscoreMapFirst.js @@ -52,8 +52,7 @@ class MyView extends View { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var MyView = (function (_super) { __extends(MyView, _super); diff --git a/tests/baselines/reference/unionTypeEquivalence.js b/tests/baselines/reference/unionTypeEquivalence.js index 04ee64b73e3..3f4ad647dd5 100644 --- a/tests/baselines/reference/unionTypeEquivalence.js +++ b/tests/baselines/reference/unionTypeEquivalence.js @@ -23,8 +23,7 @@ var z1: string | typeof BC; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // A | B is equivalent to A if B is a subtype of A var C = (function () { diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.js b/tests/baselines/reference/unionTypeFromArrayLiteral.js index ab43a6273b2..1bfadd68ca6 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.js +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.js @@ -31,8 +31,7 @@ var arr9 = [e, f]; // (E|F)[] var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var arr1 = [1, 2]; // number[] var arr2 = ["hello", true]; // (string | number)[] diff --git a/tests/baselines/reference/unionTypesAssignability.js b/tests/baselines/reference/unionTypesAssignability.js index 7778e1beded..80eafb4f506 100644 --- a/tests/baselines/reference/unionTypesAssignability.js +++ b/tests/baselines/reference/unionTypesAssignability.js @@ -76,8 +76,7 @@ function foo(t: T, u: U) { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var unionNumberString; var C = (function () { diff --git a/tests/baselines/reference/unknownSymbols1.js b/tests/baselines/reference/unknownSymbols1.js index 0e081a66b83..cab42726c73 100644 --- a/tests/baselines/reference/unknownSymbols1.js +++ b/tests/baselines/reference/unknownSymbols1.js @@ -36,8 +36,7 @@ class C5 { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var x = asdf; var y; diff --git a/tests/baselines/reference/unspecializedConstraints.js b/tests/baselines/reference/unspecializedConstraints.js index df64daff2bf..ed844f740ba 100644 --- a/tests/baselines/reference/unspecializedConstraints.js +++ b/tests/baselines/reference/unspecializedConstraints.js @@ -157,8 +157,7 @@ module ts { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var ts; (function (ts) { diff --git a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt index 624d53f95d3..c6cd96578b4 100644 --- a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt +++ b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt @@ -4,14 +4,13 @@ tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(8,10): error TS2 tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(10,7): error TS2420: Class 'C' incorrectly implements interface 'Function'. Property 'apply' is missing in type 'C'. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(18,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(20,18): error TS2311: A class may only extend another class. -tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(22,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(22,10): error TS2347: Untyped function calls may not accept type arguments. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(28,10): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(41,1): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts (10 errors) ==== +==== tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts (9 errors) ==== // none of these function calls should be allowed var x = function () { return; }; var r1 = x(); @@ -43,12 +42,10 @@ tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(41,1): error TS2 !!! error TS2349: Cannot invoke an expression whose type lacks a call signature. class C2 extends Function { } // error - ~~~~~~~~ -!!! error TS2311: A class may only extend another class. var c3: C2; var r5 = c3(); // error ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2347: Untyped function calls may not accept type arguments. interface I { (number): number; diff --git a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js index 8304aae576f..2f2d4e87c46 100644 --- a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js +++ b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js @@ -47,8 +47,7 @@ c5(1); // error var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; // none of these function calls should be allowed var x = function () { return; }; diff --git a/tests/baselines/reference/validUseOfThisInSuper.js b/tests/baselines/reference/validUseOfThisInSuper.js index 6f2fc67d7e1..4378d89ad4b 100644 --- a/tests/baselines/reference/validUseOfThisInSuper.js +++ b/tests/baselines/reference/validUseOfThisInSuper.js @@ -13,8 +13,7 @@ class Super extends Base { var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Base = (function () { function Base(b) { diff --git a/tests/baselines/reference/varArgsOnConstructorTypes.js b/tests/baselines/reference/varArgsOnConstructorTypes.js index 005ba55d761..c3daf0c1004 100644 --- a/tests/baselines/reference/varArgsOnConstructorTypes.js +++ b/tests/baselines/reference/varArgsOnConstructorTypes.js @@ -28,8 +28,7 @@ reg.register(B); var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; define(["require", "exports"], function (require, exports) { var A = (function () { diff --git a/tests/cases/compiler/classMemberWithMissingIdentifier.ts b/tests/cases/compiler/classMemberWithMissingIdentifier.ts new file mode 100644 index 00000000000..01ba223f4c4 --- /dev/null +++ b/tests/cases/compiler/classMemberWithMissingIdentifier.ts @@ -0,0 +1,3 @@ +class C { + public {}; +} \ No newline at end of file diff --git a/tests/cases/compiler/classMemberWithMissingIdentifier2.ts b/tests/cases/compiler/classMemberWithMissingIdentifier2.ts new file mode 100644 index 00000000000..e1618659797 --- /dev/null +++ b/tests/cases/compiler/classMemberWithMissingIdentifier2.ts @@ -0,0 +1,3 @@ +class C { + public {[name:string]:VariableDeclaration}; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts b/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts new file mode 100644 index 00000000000..1c20ffb0437 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts @@ -0,0 +1,12 @@ +declare module "m2" { + export module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts b/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts new file mode 100644 index 00000000000..5f942a75a74 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts @@ -0,0 +1,12 @@ +declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierForAGlobal.ts b/tests/cases/compiler/exportSpecifierForAGlobal.ts new file mode 100644 index 00000000000..c24ec0b086f --- /dev/null +++ b/tests/cases/compiler/exportSpecifierForAGlobal.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @module: commonjs + +// @filename: a.d.ts +declare class X { } + +// @filename: b.ts +export {X}; +export function f() { + var x: X; + return x; +} diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts new file mode 100644 index 00000000000..e3d0a9000ab --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts @@ -0,0 +1,5 @@ +declare module X { export interface bar { } } +declare module "m" { + export { X }; + export function foo(): X.bar; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts new file mode 100644 index 00000000000..683358a0e3b --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts @@ -0,0 +1,7 @@ +// @module: commonjs +// @Filename: exportSpecifierReferencingOuterDeclaration2_A.ts +declare module X { export interface bar { } } + +// @Filename: exportSpecifierReferencingOuterDeclaration2_B.ts +export { X }; +export declare function foo(): X.bar; \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts new file mode 100644 index 00000000000..d4ddf3cc4a6 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts @@ -0,0 +1,7 @@ +declare module X { export interface bar { } } +declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts new file mode 100644 index 00000000000..5beaf1de126 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @Filename: exportSpecifierReferencingOuterDeclaration2_A.ts +declare module X { export interface bar { } } + +// @Filename: exportSpecifierReferencingOuterDeclaration2_B.ts +declare module X { export interface foo { } } +export { X }; +export declare function foo(): X.foo; +export declare function bar(): X.bar; // error \ No newline at end of file diff --git a/tests/cases/compiler/namespacesDeclaration.ts b/tests/cases/compiler/namespacesDeclaration.ts new file mode 100644 index 00000000000..a231cf2d9d1 --- /dev/null +++ b/tests/cases/compiler/namespacesDeclaration.ts @@ -0,0 +1,9 @@ +// @declaration: true + +module M { + export namespace N { + export module M2 { + export interface I {} + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/noEmitHelpers2.ts b/tests/cases/compiler/noEmitHelpers2.ts index ccc17f7066e..2487ffa1dd8 100644 --- a/tests/cases/compiler/noEmitHelpers2.ts +++ b/tests/cases/compiler/noEmitHelpers2.ts @@ -3,7 +3,7 @@ // @emitdecoratormetadata: true // @target: es5 -function decorator() { } +declare var decorator: any; @decorator class A { diff --git a/tests/cases/compiler/numLit.ts b/tests/cases/compiler/numLit.ts deleted file mode 100644 index 01e19e7c8fb..00000000000 --- a/tests/cases/compiler/numLit.ts +++ /dev/null @@ -1,4 +0,0 @@ -1..toString(); -1.0.toString(); -1.toString(); -1.+2.0 + 3. ; \ No newline at end of file diff --git a/tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts b/tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts new file mode 100644 index 00000000000..23cd2ba45f8 --- /dev/null +++ b/tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts @@ -0,0 +1,17 @@ +1..toString(); +1.0.toString(); +1.toString(); +1.+2.0 + 3. ; + +// Preserve whitespace where important for JS compatibility +var i: number = 1; +var test1 = i.toString(); +var test2 = 2.toString(); +var test3 = 3 .toString(); +var test4 = 3 .toString(); +var test5 = 3 .toString(); +var test6 = 3.['toString'](); +var test7 = 3 +.toString(); +var test8 = new Number(4).toString(); +var test9 = 3. + 3. diff --git a/tests/cases/compiler/sourceMapValidationDecorators.ts b/tests/cases/compiler/sourceMapValidationDecorators.ts index 898d3f729b2..b600691e04b 100644 --- a/tests/cases/compiler/sourceMapValidationDecorators.ts +++ b/tests/cases/compiler/sourceMapValidationDecorators.ts @@ -5,8 +5,8 @@ declare function ClassDecorator1(target: Function): void; declare function ClassDecorator2(x: number): (target: Function) => void; declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; -declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void; -declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void; +declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; +declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; @ClassDecorator1 @ClassDecorator2(10) diff --git a/tests/cases/compiler/systemModule13.ts b/tests/cases/compiler/systemModule13.ts new file mode 100644 index 00000000000..2f92d99ab21 --- /dev/null +++ b/tests/cases/compiler/systemModule13.ts @@ -0,0 +1,5 @@ +// @module: system + +export let [x,y,z] = [1, 2, 3]; +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +for ([x] of [[1]]) {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts new file mode 100644 index 00000000000..f36da74ea71 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts @@ -0,0 +1,10 @@ +class C1 extends Object { } +class C2 extends Function { } +class C3 extends String { } +class C4 extends Boolean { } +class C5 extends Number { } +class C6 extends Date { } +class C7 extends RegExp { } +class C8 extends Error { } +class C9 extends Array { } +class C10 extends Array { } diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts new file mode 100644 index 00000000000..a9f2a3049ed --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts @@ -0,0 +1,57 @@ +interface Base { + x: T; + y: U; +} + +// Error, no Base constructor function +class D0 extends Base { +} + +interface BaseConstructor { + new (x: string, y: string): Base; + new (x: T): Base; + new (x: T, y: T): Base; + new (x: T, y: U): Base; +} + +declare function getBase(): BaseConstructor; + +class D1 extends getBase() { + constructor() { + super("abc", "def"); + this.x = "x"; + this.y = "y"; + } +} + +class D2 extends getBase() { + constructor() { + super(10); + super(10, 20); + this.x = 1; + this.y = 2; + } +} + +class D3 extends getBase() { + constructor() { + super("abc", 42); + this.x = "x"; + this.y = 2; + } +} + +// Error, no constructors with three type arguments +class D4 extends getBase() { +} + +interface BadBaseConstructor { + new (x: string): Base; + new (x: number): Base; +} + +declare function getBadBase(): BadBaseConstructor; + +// Error, constructor return types differ +class D5 extends getBadBase() { +} diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts new file mode 100644 index 00000000000..4b7e5c7a76e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts @@ -0,0 +1,13 @@ +var x: {}; + +function foo() { + this.x = 1; +} + +class C1 extends undefined { } +class C2 extends true { } +class C3 extends false { } +class C4 extends 42 { } +class C5 extends "hello" { } +class C6 extends x { } +class C7 extends foo { } diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts new file mode 100644 index 00000000000..655cf44ed57 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts @@ -0,0 +1,2 @@ +class C1 extends null { } +class C2 extends (null) { } diff --git a/tests/cases/conformance/classes/classExpressions/classExpression3.ts b/tests/cases/conformance/classes/classExpressions/classExpression3.ts new file mode 100644 index 00000000000..4267429f759 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classExpression3.ts @@ -0,0 +1,5 @@ +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +let c = new C(); +c.a; +c.b; +c.c; diff --git a/tests/cases/conformance/classes/classExpressions/classExpression4.ts b/tests/cases/conformance/classes/classExpressions/classExpression4.ts new file mode 100644 index 00000000000..9365475fd87 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classExpression4.ts @@ -0,0 +1,6 @@ +let C = class { + foo() { + return new C(); + } +}; +let x = (new C).foo(); diff --git a/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts b/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts index 95f8bf4ab97..f2d9076cce2 100644 --- a/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts +++ b/tests/cases/conformance/decorators/class/decoratedClassFromExternalModule.ts @@ -1,7 +1,7 @@ // @target: es6 // @experimentaldecorators: true // @Filename: decorated.ts -function decorate() { } +function decorate(target: any) { } @decorate export default class Decorated { } diff --git a/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts b/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts index b1cbd1a679c..36237f3cb58 100644 --- a/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts +++ b/tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts @@ -6,7 +6,7 @@ function func(s: string): void { } class A { - @(x => { + @((x, p) => { var a = 3; func(a); return x; diff --git a/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts b/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts index 9163ed0c384..7ba5a6839b9 100644 --- a/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts +++ b/tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts @@ -10,7 +10,7 @@ export var test = 'abc'; import { test } from './a'; function filter(handler: any) { - return function (target: any) { + return function (target: any, propertyKey: string) { // ... }; } diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts index f41481d4ad0..5ab3b39d7ab 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts @@ -1,6 +1,6 @@ // @target: ES6 // @experimentaldecorators: true -declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class C { @dec ["1"]() { } diff --git a/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts index 18a7fff6dd0..64de61bb8a9 100644 --- a/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts +++ b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts @@ -1,6 +1,6 @@ // @target:es5 // @experimentaldecorators: true -declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; class C { method(@dec p: number) {} diff --git a/tests/cases/conformance/decorators/missingDecoratorType.ts b/tests/cases/conformance/decorators/missingDecoratorType.ts index 905edaf0756..9b8cdd276f2 100644 --- a/tests/cases/conformance/decorators/missingDecoratorType.ts +++ b/tests/cases/conformance/decorators/missingDecoratorType.ts @@ -13,9 +13,10 @@ interface RegExp { } interface IArguments { } // @Filename: b.ts -declare var dec: any; +declare function dec(t, k, d); -@dec class C { + @dec + method() {} } diff --git a/tests/cases/conformance/es6/classExpressions/classExpressionES63.ts b/tests/cases/conformance/es6/classExpressions/classExpressionES63.ts new file mode 100644 index 00000000000..cbbe0927c30 --- /dev/null +++ b/tests/cases/conformance/es6/classExpressions/classExpressionES63.ts @@ -0,0 +1,6 @@ +// @target: es6 +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +let c = new C(); +c.a; +c.b; +c.c; diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts new file mode 100644 index 00000000000..0dea1fe795c --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts @@ -0,0 +1,5 @@ + + +function f([]) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts new file mode 100644 index 00000000000..39663a4bed7 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts @@ -0,0 +1,5 @@ + + +function f(a, []) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts new file mode 100644 index 00000000000..39663a4bed7 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts @@ -0,0 +1,5 @@ + + +function f(a, []) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts new file mode 100644 index 00000000000..313d4fe6708 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts @@ -0,0 +1,5 @@ + + +function f([] = [1,2,3,4]) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts new file mode 100644 index 00000000000..01aa5b54230 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts @@ -0,0 +1,5 @@ + + +function f({}) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts new file mode 100644 index 00000000000..f34503c1152 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts @@ -0,0 +1,5 @@ + + +function f(a, {}) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts new file mode 100644 index 00000000000..a940c659703 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts @@ -0,0 +1,5 @@ + + +function f({}, a) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts new file mode 100644 index 00000000000..da05e5cb428 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts @@ -0,0 +1,5 @@ + + +function f({} = {a: 1, b: "2", c: true}) { + var x, y, z; +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperator1.ts b/tests/cases/conformance/expressions/asOperator/asOperator1.ts new file mode 100644 index 00000000000..cf953d75ab4 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator1.ts @@ -0,0 +1,8 @@ +var as = 43; +var x = undefined as number; +var y = (null as string).length; +var z = Date as any as string; + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +j = ''; diff --git a/tests/cases/conformance/expressions/asOperator/asOperator2.ts b/tests/cases/conformance/expressions/asOperator/asOperator2.ts new file mode 100644 index 00000000000..1fa5f2c938d --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator2.ts @@ -0,0 +1 @@ +var x = 23 as string; diff --git a/tests/cases/conformance/expressions/asOperator/asOperator3.ts b/tests/cases/conformance/expressions/asOperator/asOperator3.ts new file mode 100644 index 00000000000..4c136247e00 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator3.ts @@ -0,0 +1,10 @@ +declare function tag(...x: any[]): any; + +var a = `${123 + 456 as number}`; +var b = `leading ${123 + 456 as number}`; +var c = `${123 + 456 as number} trailing`; +var d = `Hello ${123} World` as string; +var e = `Hello` as string; +var f = 1 + `${1} end of string` as string; +var g = tag `Hello ${123} World` as string; +var h = tag `Hello` as string; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts b/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts new file mode 100644 index 00000000000..a4dd44a15ad --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts @@ -0,0 +1,10 @@ +class Foo { } +declare function as(...args: any[]); + +// Example 1 +var x = 10 +as `Hello world`; // should not error + +// Example 2 +var y = 20 +as(Foo); // should emit diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts b/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts new file mode 100644 index 00000000000..e4921314ba7 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts @@ -0,0 +1,8 @@ +interface A { x: T; } +interface B { m: string; } + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +var y = x as A[]; +var z = y[0].m; // z should be string + diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts b/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts new file mode 100644 index 00000000000..d3a23e224ba --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts @@ -0,0 +1,2 @@ +// should error +var x = (v => v) as (x: number) => string; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts b/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts new file mode 100644 index 00000000000..a0b54d43e84 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts @@ -0,0 +1,4 @@ +var a = 20; +var b = a as string; +var as = "hello"; +var as1 = as as string; diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts index e157b2afe36..688099280c5 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts @@ -23,6 +23,10 @@ function hasMissingIsKeyword(): x { return true; } +function hasMissingParameter(): x is A { + return true; +} + function hasMissingTypeInTypeGuardType(x): x is { return true; } @@ -132,4 +136,10 @@ function b6([a, b, p1], p2, p3): p1 is A { function b7({a, b, c: {p1}}, p2, p3): p1 is A { return true; +} + +// Should not crash the compiler +var x: A; +if (hasMissingParameter()) { + x.propA; } \ No newline at end of file diff --git a/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx b/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx new file mode 100644 index 00000000000..b20dea210a9 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx @@ -0,0 +1,22 @@ +// @jsx: preserve + +declare var createElement: any; + +class foo {} + +var x: any; +x = { test: }; + +x = ; + +x = hello {{}} ; + +x = {}}>hello; + +x = {}}>hello{{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + + diff --git a/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx b/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx new file mode 100644 index 00000000000..163357454aa --- /dev/null +++ b/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx @@ -0,0 +1,54 @@ +// @jsx: preserve +declare var React: any; +declare var 日本語; +declare var AbC_def; +declare var LeftRight; +declare var x; +declare var a; +declare var props; + +; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; + +; +; + +<日本語>; + + +bar +baz +; + + : } />; + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + +; + +; + +(
) < x; + +
; + +
; + +
; + + ; diff --git a/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx new file mode 100644 index 00000000000..815cd4abb21 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx @@ -0,0 +1,36 @@ +// @jsx: preserve +declare var React: any; + +; +; +<:a />; +; +; +
; +; +; +
; +
; + +
stuff
; +
stuff
; + +
>; + >; +; +; +}; +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/jsxReactTestSuite.tsx b/tests/cases/conformance/jsx/jsxReactTestSuite.tsx new file mode 100644 index 00000000000..96b91987cbc --- /dev/null +++ b/tests/cases/conformance/jsx/jsxReactTestSuite.tsx @@ -0,0 +1,117 @@ +// @jsx: preserve + +declare var React: any; +declare var Component:any; +declare var Composite:any; +declare var Composite2:any; +declare var Child:any; +declare var Namespace:any; +declare var foo: any; +declare var bar: any; +declare var y:any; +declare var x:any; +declare var z:any; +declare var hasOwnProperty:any; + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+
+
; + + + + {this.props.children} +; + + + +; + +var x = +
+
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+ +
+); + +
 
; + +
 
; + +testing; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + + +; + +Text; + + diff --git a/tests/cases/conformance/jsx/tsxAttributeErrors.tsx b/tests/cases/conformance/jsx/tsxAttributeErrors.tsx new file mode 100644 index 00000000000..477135e1544 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeErrors.tsx @@ -0,0 +1,26 @@ +// @jsx: preserve + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } +} + +// Error, number is not assignable to string +
; + +// Error, string is not assignable to number +
; + +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; + +// No errors here +; diff --git a/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx new file mode 100644 index 00000000000..4471c5a9c92 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx @@ -0,0 +1,13 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; + } +} + +// Invalid names +; +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution.tsx new file mode 100644 index 00000000000..3e5d8e3a7c8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution.tsx @@ -0,0 +1,9 @@ +//@jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + x: { y: number; z: string; }; + } +} + + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx new file mode 100644 index 00000000000..fb54f9d7c82 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx @@ -0,0 +1,15 @@ +// OK +; // OK +; // OK +; // OK +; // OK +; // OK +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property +; // Error, missing reqd +; // Error, reqd is not string diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx new file mode 100644 index 00000000000..edb203655ef --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx @@ -0,0 +1,33 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + } +} +interface Attribs1 { + x?: number; + s?: string; +} + +// OK +; // OK +; // OK +; // OK + +; // OK +; // OK + +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +// TODO attribute 'var' should be parseable +// ; // Error, no 'var' property + +; // Error, missing reqd +; // Error, reqd is not string + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx new file mode 100644 index 00000000000..7c47046dcde --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx @@ -0,0 +1,5 @@ +// OK +; // OK +; // OK +// Errors +; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx new file mode 100644 index 00000000000..c9bc2de978a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + c1?: (x: string) => void; +} + +// OK + x.length} />; // OK + x.leng} />; // OK + + +// Errors + x.leng} />; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx new file mode 100644 index 00000000000..46cb5d8ff69 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx @@ -0,0 +1,21 @@ +// OK +var obj1 = { x: 'foo' }; +; +// Error, x is not string +var obj2 = { x: 32 }; +; +// Error, x is missing +var obj3 = { y: 32 }; +; +// OK +var obj4 = { x: 32, y: 32 }; +; +// Error +var obj5 = { x: 32, y: 32 }; +; +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; +; +// Error +var obj7 = { x: 'foo' }; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx new file mode 100644 index 00000000000..dc0c2fed8d6 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x: string; + y?: number; + z?: string; +} + +// OK +var obj1 = { x: 'foo' }; + + +// Error, x is not string +var obj2 = { x: 32 }; + + +// Error, x is missing +var obj3 = { y: 32 }; + + +// OK +var obj4 = { x: 32, y: 32 }; + + +// Error +var obj5 = { x: 32, y: 32 }; + + +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; + + +// Error +var obj7 = { x: 'foo' }; + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx new file mode 100644 index 00000000000..da2e1d12038 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx @@ -0,0 +1,4 @@ +// OK +; +// Error, no member 'len' on 'string' +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx new file mode 100644 index 00000000000..caaad3559c3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx @@ -0,0 +1,17 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x(n: string): void; +} + +// OK + 0} } />; + +// Error, no member 'len' on 'string' + n.len} } />; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx new file mode 100644 index 00000000000..3e4c89d06fb --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx @@ -0,0 +1,11 @@ +function make1(obj) { + return ; // OK +} +function make2(obj) { + return ; // Error (x is number, not string) +} +function make3(obj) { + return ; // Error, missing x +} +; // Error, missing x +; // OK diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx new file mode 100644 index 00000000000..dd16ade10e3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx @@ -0,0 +1,32 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } +} +interface Attribs1 { + x: string; +} + +interface Attribs2 { + toString(): string; +} + +function make1 (obj: T) { + return ; // OK +} + +function make2 (obj: T) { + return ; // Error (x is number, not string) +} + +function make3 (obj: T) { + return ; // Error, missing x +} + + +; // Error, missing x +; // OK diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx new file mode 100644 index 00000000000..b083247ba7a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } +} + +// Error +; +; +; + +// OK +; +; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx new file mode 100644 index 00000000000..1fc6a873187 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx @@ -0,0 +1,16 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Error +; + +// OK +; +; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx new file mode 100644 index 00000000000..ac99cd15593 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: {x: string}; + } +} + +var x: any; +// Should be OK + \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution.tsx b/tests/cases/conformance/jsx/tsxElementResolution.tsx new file mode 100644 index 00000000000..e5c3c191f05 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution.tsx @@ -0,0 +1,25 @@ +//@jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } +} + +class foundFirst { } +class Other {} + +module Dotted { + export class Name { } +} + +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.jsx b/tests/cases/conformance/jsx/tsxElementResolution1.jsx new file mode 100644 index 00000000000..97357dbba8e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution1.jsx @@ -0,0 +1,4 @@ +// OK +
; +// Fail +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.tsx b/tests/cases/conformance/jsx/tsxElementResolution1.tsx new file mode 100644 index 00000000000..b9c1b91d05e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution1.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +// OK +
; + +// Fail +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution10.tsx b/tests/cases/conformance/jsx/tsxElementResolution10.tsx new file mode 100644 index 00000000000..526c0529e1b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution10.tsx @@ -0,0 +1,21 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): { x: number }; +} +var Obj1: Obj1type; +; // Error, no render member + +interface Obj2type { + (n: string): { x: number; render: any; }; +} +var Obj2: Obj2type; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.jsx b/tests/cases/conformance/jsx/tsxElementResolution11.jsx new file mode 100644 index 00000000000..6349906508c --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution11.jsx @@ -0,0 +1,6 @@ +var Obj1; +; // OK +var Obj2; +; // Error +var Obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.tsx b/tests/cases/conformance/jsx/tsxElementResolution11.tsx new file mode 100644 index 00000000000..0fc74335500 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution11.tsx @@ -0,0 +1,25 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number }; +} +var Obj2: Obj2type; +; // Error + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.jsx b/tests/cases/conformance/jsx/tsxElementResolution12.jsx new file mode 100644 index 00000000000..ef137fd0e29 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution12.jsx @@ -0,0 +1,9 @@ +var obj1; +; // OK +var obj2; +; // OK +var obj3; +; // Error +var obj4; +; // OK +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.tsx b/tests/cases/conformance/jsx/tsxElementResolution12.tsx new file mode 100644 index 00000000000..a5d8f2d812b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution12.tsx @@ -0,0 +1,32 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number; pr: any }; +} +var obj2: Obj2type; +; // OK + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // Error + +interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; +} +var Obj4: Obj4type; +; // OK +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.jsx b/tests/cases/conformance/jsx/tsxElementResolution13.jsx new file mode 100644 index 00000000000..6a55efa612d --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution13.jsx @@ -0,0 +1,2 @@ +var obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.tsx b/tests/cases/conformance/jsx/tsxElementResolution13.tsx new file mode 100644 index 00000000000..32ee20afbfe --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution13.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } +} + +interface Obj1 { + new(n: string): any; +} +var obj1: Obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.jsx b/tests/cases/conformance/jsx/tsxElementResolution14.jsx new file mode 100644 index 00000000000..29df7710af1 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution14.jsx @@ -0,0 +1,2 @@ +var obj1; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.tsx b/tests/cases/conformance/jsx/tsxElementResolution14.tsx new file mode 100644 index 00000000000..f76af00bbeb --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution14.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.jsx b/tests/cases/conformance/jsx/tsxElementResolution15.jsx new file mode 100644 index 00000000000..6a55efa612d --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution15.jsx @@ -0,0 +1,2 @@ +var obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.tsx b/tests/cases/conformance/jsx/tsxElementResolution15.tsx new file mode 100644 index 00000000000..61cea63ce76 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution15.tsx @@ -0,0 +1,13 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): {}; +} +var Obj1: Obj1type; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.jsx b/tests/cases/conformance/jsx/tsxElementResolution16.jsx new file mode 100644 index 00000000000..e1987489bbb --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution16.jsx @@ -0,0 +1,2 @@ +var obj1; +; // Error (JSX.Element is missing) diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.tsx b/tests/cases/conformance/jsx/tsxElementResolution16.tsx new file mode 100644 index 00000000000..3b5b23d77f5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution16.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +//@noImplicitAny: true +declare module JSX { +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // Error (JSX.Element is implicit any) diff --git a/tests/cases/conformance/jsx/tsxElementResolution17.tsx b/tests/cases/conformance/jsx/tsxElementResolution17.tsx new file mode 100644 index 00000000000..97777d76a58 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution17.tsx @@ -0,0 +1,27 @@ +//@jsx: preserve +//@module: amd + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +declare module 'elements1' { + class MyElement { + + } +} + +declare module 'elements2' { + class MyElement { + + } +} + +//@filename: consumer.tsx +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +import s2 = require('elements2'); +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution18.tsx b/tests/cases/conformance/jsx/tsxElementResolution18.tsx new file mode 100644 index 00000000000..89081d7629f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution18.tsx @@ -0,0 +1,9 @@ +//@jsx: preserve +//@filename: file1.tsx +//@noimplicitany: true +declare module JSX { + interface Element { } +} + +// Error under implicit any +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution2.tsx b/tests/cases/conformance/jsx/tsxElementResolution2.tsx new file mode 100644 index 00000000000..75e4956e728 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution2.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: any; + } +} + +// OK +
; + +// OK +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution3.tsx b/tests/cases/conformance/jsx/tsxElementResolution3.tsx new file mode 100644 index 00000000000..c3f057c4ff5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution3.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } +} + +// OK +
; + +// Error +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution4.tsx b/tests/cases/conformance/jsx/tsxElementResolution4.tsx new file mode 100644 index 00000000000..413ae6d5ed9 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution4.tsx @@ -0,0 +1,18 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } +} + +// OK +
; + +// OK +; + +// Error +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution5.tsx b/tests/cases/conformance/jsx/tsxElementResolution5.tsx new file mode 100644 index 00000000000..c12c07d3e60 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution5.tsx @@ -0,0 +1,8 @@ +//@jsx: preserve +//@filename: file1.tsx +declare module JSX { + interface Element { } +} + +// OK, but implicit any +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution6.tsx b/tests/cases/conformance/jsx/tsxElementResolution6.tsx new file mode 100644 index 00000000000..74d3324ea0f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution6.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +var div: any; +// Still an error +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.jsx b/tests/cases/conformance/jsx/tsxElementResolution7.jsx new file mode 100644 index 00000000000..e95505539ab --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution7.jsx @@ -0,0 +1,14 @@ +var my; +(function (my) { +})(my || (my = {})); +// OK +; +// Error +; +var q; +(function (q) { + // OK + ; + // Error + ; +})(q || (q = {})); diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.tsx b/tests/cases/conformance/jsx/tsxElementResolution7.tsx new file mode 100644 index 00000000000..c7ab23e76ea --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution7.tsx @@ -0,0 +1,22 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module my { + export var div: any; +} +// OK +; +// Error +; + +module q { + import mine = my; + // OK + ; + // Error + ; +} diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.jsx b/tests/cases/conformance/jsx/tsxElementResolution8.jsx new file mode 100644 index 00000000000..e0f95dc6d22 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution8.jsx @@ -0,0 +1,15 @@ +// Error +var div = 3; +
; +// OK +function fact() { return null; } +; +// Error +function fnum() { return 42; } +; +var obj1; +; // OK, prefer construct signatures +var obj2; +; // Error +var obj3; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.tsx b/tests/cases/conformance/jsx/tsxElementResolution8.tsx new file mode 100644 index 00000000000..624302da062 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution8.tsx @@ -0,0 +1,36 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +// Error +var Div = 3; +
; + +// OK +function Fact(): any { return null; } + + +// Error +function Fnum(): number{ return 42; } + + +interface Obj1 { + new(): {}; + (): number; +} +var Obj1: Obj1; +; // OK, prefer construct signatures + +interface Obj2 { + (): number; +} +var Obj2: Obj2; +; // Error + +interface Obj3 { +} +var Obj3: Obj3; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.jsx b/tests/cases/conformance/jsx/tsxElementResolution9.jsx new file mode 100644 index 00000000000..2b62d86eac5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution9.jsx @@ -0,0 +1,6 @@ +var obj1; +; // Error, return type is not an object type +var obj2; +; // Error, return type is not an object type +var obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.tsx b/tests/cases/conformance/jsx/tsxElementResolution9.tsx new file mode 100644 index 00000000000..7165f8277b3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution9.tsx @@ -0,0 +1,27 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; +} +var Obj1: Obj1; +; // Error, return type is not an object type + +interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; +} +var Obj2: Obj2; +; // Error, return type is not an object type + +interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; +} +var Obj3: Obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxEmit1.jsx b/tests/cases/conformance/jsx/tsxEmit1.jsx new file mode 100644 index 00000000000..45ca6e2469f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit1.jsx @@ -0,0 +1,34 @@ +var p; +/* +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; +*/ +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 =
{function () { return _this; }}
; + var rewrites4 =
; + }; + return SomeClass; +})(); +/* +var q = () => this; +var rewrites2 =
{[p, ...p, p]}
; +var rewrites3 =
{{p}}
; + +var rewrites5 =
; +var rewrites6 =
; +*/ diff --git a/tests/cases/conformance/jsx/tsxEmit1.tsx b/tests/cases/conformance/jsx/tsxEmit1.tsx new file mode 100644 index 00000000000..9f3d9ca3a5e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit1.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/cases/conformance/jsx/tsxEmit2.tsx b/tests/cases/conformance/jsx/tsxEmit2.tsx new file mode 100644 index 00000000000..24f51a4583d --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit2.tsx @@ -0,0 +1,15 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxEmit3.jsx b/tests/cases/conformance/jsx/tsxEmit3.jsx new file mode 100644 index 00000000000..7c979051d00 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit3.jsx @@ -0,0 +1,41 @@ +var M; +(function (M) { + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + M.Foo = Foo; + var S; + (function (S) { + var Bar = (function () { + function Bar() { + } + return Bar; + })(); + S.Bar = Bar; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.Foo + M.Foo, ; + var S; + (function (S) { + // Emit M.Foo + M.Foo, ; + // Emit S.Bar + S.Bar, ; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.S.Bar + M.S.Bar, ; +})(M || (M = {})); +var M; +(function (M_1) { + var M = 100; + // Emit M_1.Foo + M_1.Foo, ; +})(M || (M = {})); diff --git a/tests/cases/conformance/jsx/tsxEmit3.tsx b/tests/cases/conformance/jsx/tsxEmit3.tsx new file mode 100644 index 00000000000..b3c3350dd11 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit3.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module M { + export class Foo { constructor() { } } + export module S { + export class Bar { } + + // Emit Foo + // Foo, ; + } +} + +module M { + // Emit M.Foo + Foo, ; + + export module S { + // Emit M.Foo + Foo, ; + + // Emit S.Bar + Bar, ; + } + +} + +module M { + // Emit M.S.Bar + S.Bar, ; +} + +module M { + var M = 100; + // Emit M_1.Foo + Foo, ; +} diff --git a/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx b/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx new file mode 100644 index 00000000000..881b3c95376 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve + +declare namespace JSX { interface Element { } } + +function foo() { + var x =
{
+} +// Shouldn't see any errors down here +var y = { a: 1 }; diff --git a/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx b/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx new file mode 100644 index 00000000000..bb7f5c3f361 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx @@ -0,0 +1,32 @@ +//@jsx: preserve +//@module: commonjs + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +// Should see var button_1 = require('./button') here +import { Button } from './button'; + +export class App extends React.Component { + + render() { + return ; + } + +} \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx b/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx new file mode 100644 index 00000000000..b3d3d34020a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx @@ -0,0 +1,28 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { isElement; } +} + +var T, T1, T2; + +// This is an element +var x1 = () => {}; +x1.isElement; + +// This is a generic function +var x2 = () => {}; +x2(); + +// This is a generic function +var x3 = () => {}; +x3(); + +// This is an element +var x4 = () => {}; +x4.isElement; + +// This is an element +var x5 = () => {}; +x5.isElement; + diff --git a/tests/cases/conformance/jsx/tsxInArrowFunction.tsx b/tests/cases/conformance/jsx/tsxInArrowFunction.tsx new file mode 100644 index 00000000000..36951e0d092 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxInArrowFunction.tsx @@ -0,0 +1,23 @@ +// @jsx: preserve + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + } + } +} + + +// didn't work +
{() =>
}
; + +// didn't work +
{x =>
}
; + +// worked +
{() => (
)}
; + +// worked (!) +
{() =>
}
; diff --git a/tests/cases/conformance/jsx/tsxNoJsx.tsx b/tests/cases/conformance/jsx/tsxNoJsx.tsx new file mode 100644 index 00000000000..03b827b7e61 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNoJsx.tsx @@ -0,0 +1,3 @@ +//@jsx: preserve + +; diff --git a/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx b/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx new file mode 100644 index 00000000000..8f21517474f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } +} + +declare module A.B.C { + var D: any; +} + +foo diff --git a/tests/cases/conformance/jsx/tsxParseTests1.tsx b/tests/cases/conformance/jsx/tsxParseTests1.tsx new file mode 100644 index 00000000000..7675aee7962 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxParseTests1.tsx @@ -0,0 +1,8 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx new file mode 100644 index 00000000000..b8f14b0ba22 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit2.tsx b/tests/cases/conformance/jsx/tsxReactEmit2.tsx new file mode 100644 index 00000000000..39a78a7da87 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit2.tsx @@ -0,0 +1,15 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit3.tsx b/tests/cases/conformance/jsx/tsxReactEmit3.tsx new file mode 100644 index 00000000000..eb63be44f3b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit3.tsx @@ -0,0 +1,8 @@ +//@jsx: react +//@filename: test.tsx + +declare module JSX { interface Element { } } + +declare var Foo, Bar, baz; + + q s ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx new file mode 100644 index 00000000000..f007c35c24a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -0,0 +1,18 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var openClosed1 =
+ + {blah} + +
; + +// Should emit React.__spread({}, p, {x: 0}) +var spread1 =
; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx new file mode 100644 index 00000000000..38c966fa700 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -0,0 +1,52 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +// Emit " " +
; +// Emit " ", p, " " +
{p}
; +// Emit only p +
+ {p} +
; + +// Emit only p +
+ {p} +
; + +// Emit " 3" +
3 +
; + +// Emit " 3 " +
3
; + +// Emit "3" +
+ 3 +
; + +// Emit no args +
+
; + +// Emit "foo" + ' ' + "bar" +
+ + foo + + bar + +
; + diff --git a/tests/cases/conformance/jsx/tsxTypeErrors.tsx b/tests/cases/conformance/jsx/tsxTypeErrors.tsx new file mode 100644 index 00000000000..f8288b68ce3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxTypeErrors.tsx @@ -0,0 +1,34 @@ +//@jsx: preserve + +// A built-in element (OK) +var a1 =
; + +// A built-in element with a mistyped property (error) +var a2 = + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
+ +// Mistyped html name (error) +var e1 = + +// A custom type +class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; + diff --git a/tests/cases/fourslash/asOperatorFormatting.ts b/tests/cases/fourslash/asOperatorFormatting.ts new file mode 100644 index 00000000000..f697ffd8bb6 --- /dev/null +++ b/tests/cases/fourslash/asOperatorFormatting.ts @@ -0,0 +1,7 @@ +/// + +//// /**/var x = 3 as number; + +goTo.marker(); +format.document(); +verify.currentLineContentIs("var x = 3 as number;"); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts new file mode 100644 index 00000000000..128e95b8ed3 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts @@ -0,0 +1,13 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { /**/ } = foo; + +goTo.marker(); +verify.completionListContains("property1"); +verify.completionListContains("property2"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts new file mode 100644 index 00000000000..6d2b7a6b516 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts @@ -0,0 +1,13 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { property1, /**/ } = foo; + +goTo.marker(); +verify.completionListContains("property2"); +verify.not.completionListContains("property1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern03.ts b/tests/cases/fourslash/completionListInObjectBindingPattern03.ts new file mode 100644 index 00000000000..72da68168bd --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern03.ts @@ -0,0 +1,13 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { property1: /**/ } = foo; + +goTo.marker(); +verify.completionListAllowsNewIdentifier(); +verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts new file mode 100644 index 00000000000..92b202a1b37 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts @@ -0,0 +1,13 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { prope/**/ } = foo; + +goTo.marker(); +verify.completionListContains("property1"); +verify.completionListContains("property2"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts new file mode 100644 index 00000000000..d17e11810df --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts @@ -0,0 +1,12 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { property1/**/ } = foo; + +goTo.marker(); +verify.completionListContains("property1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern06.ts b/tests/cases/fourslash/completionListInObjectBindingPattern06.ts new file mode 100644 index 00000000000..8060c2bde78 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern06.ts @@ -0,0 +1,12 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { property1, property2, /**/ } = foo; + +goTo.marker(); +verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts new file mode 100644 index 00000000000..a3015346aa3 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// propertyOfI_1: number; +//// propertyOfI_2: string; +////} +////interface J { +//// property1: I; +//// property2: string; +////} +//// +////var foo: J; +////var { property1: { /**/ } } = foo; + +goTo.marker(); +verify.completionListContains("propertyOfI_1"); +verify.completionListContains("propertyOfI_2"); +verify.not.completionListContains("property2"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts new file mode 100644 index 00000000000..6d6be330b83 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// propertyOfI_1: number; +//// propertyOfI_2: string; +////} +////interface J { +//// property1: I; +//// property2: string; +////} +//// +////var foo: J; +////var { property1: { propertyOfI_1, /**/ } } = foo; + +goTo.marker(); +verify.completionListContains("propertyOfI_2"); +verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListContains("property2"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts new file mode 100644 index 00000000000..2698e78667b --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// propertyOfI_1: number; +//// propertyOfI_2: string; +////} +////interface J { +//// property1: I; +//// property2: string; +////} +//// +////var foo: J; +////var { property1: { propertyOfI_1, }, /**/ } = foo; + +goTo.marker(); +verify.completionListContains("property2"); +verify.not.completionListContains("property1"); +verify.not.completionListContains("propertyOfI_2"); +verify.not.completionListContains("propertyOfI_1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts new file mode 100644 index 00000000000..fcc09d1ead4 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts @@ -0,0 +1,23 @@ +/// + +////interface I { +//// propertyOfI_1: number; +//// propertyOfI_2: string; +////} +////interface J { +//// property1: I; +//// property2: string; +////} +//// +////var foo: J[]; +////var [{ property1: { propertyOfI_1, }, /*1*/ }, { /*2*/ }] = foo; + +goTo.marker("1"); +verify.completionListContains("property2"); +verify.not.completionListContains("property1"); +verify.not.completionListContains("propertyOfI_2"); +verify.not.completionListContains("propertyOfI_1"); + +goTo.marker("2"); +verify.completionListContains("property1"); +verify.completionListContains("property2"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts new file mode 100644 index 00000000000..25d6651a038 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts @@ -0,0 +1,13 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var { property1: prop1, /**/ }: I; + +goTo.marker(""); +verify.completionListContains("property2"); +verify.not.completionListContains("property1"); +verify.not.completionListContains("prop1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts new file mode 100644 index 00000000000..f31206a21b6 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts @@ -0,0 +1,13 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////function f({ property1, /**/ }: I): void { +////} + +goTo.marker(""); +verify.completionListContains("property2"); +verify.not.completionListContains("property1"); \ No newline at end of file diff --git a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts index ec2ae9b3c22..3692974f5fb 100644 --- a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts +++ b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts @@ -18,4 +18,4 @@ goTo.marker("1"); edit.insert("\r\n"); goTo.marker("0"); // Won't-fixed: Smart indent during chained function calls -verify.indentationIs(4); \ No newline at end of file +verify.indentationIs(8); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts new file mode 100644 index 00000000000..2f40af93c02 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -0,0 +1,18 @@ +/// + +////export default class [|DefaultExportedClass|] { +////} +//// +////var x: [|DefaultExportedClass|]; +//// +////var y = new [|DefaultExportedClass|]; + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts new file mode 100644 index 00000000000..db773c74e3c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -0,0 +1,19 @@ +/// + +////export default function [|DefaultExportedFunction|]() { +//// return [|DefaultExportedFunction|] +////} +//// +////var x: typeof [|DefaultExportedFunction|]; +//// +////var y = [|DefaultExportedFunction|](); + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts new file mode 100644 index 00000000000..f753d17de49 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts @@ -0,0 +1,25 @@ +/// + +////function [|f|]() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace [|f|] { +//// var local = 100; +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts new file mode 100644 index 00000000000..45b008b55fe --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts @@ -0,0 +1,28 @@ +/// + +////function f() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof f; +//// +////var y = f(); +//// +////namespace /**/[|f|] { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' +// site is included in the references to the namespace. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport05.ts b/tests/cases/fourslash/findAllRefsForDefaultExport05.ts new file mode 100644 index 00000000000..6655138da3b --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport05.ts @@ -0,0 +1,28 @@ +/// + +////function /**/[|f|]() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace f { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' site +// and all value-uses of 'f' are included in the references to the function. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport06.ts b/tests/cases/fourslash/findAllRefsForDefaultExport06.ts new file mode 100644 index 00000000000..12c187b4b0c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport06.ts @@ -0,0 +1,28 @@ +/// + +////function [|f|]() { +//// return 100; +////} +//// +////export default /**/[|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace [|f|] { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' site +// and all value-uses of 'f' are included in the references to the function. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport07.ts b/tests/cases/fourslash/findAllRefsForDefaultExport07.ts new file mode 100644 index 00000000000..9534a671316 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport07.ts @@ -0,0 +1,18 @@ +/// + +////export default function DefaultExportedFunction() { +//// return DefaultExportedFunction +////} +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); +//// +////namespace /**/DefaultExportedFunction { +////} + +// The namespace and function do not merge, +// so the namespace should be all alone. + +goTo.marker(); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport08.ts b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts new file mode 100644 index 00000000000..80eabbe53f4 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts @@ -0,0 +1,17 @@ +/// + +////export default class DefaultExportedClass { +////} +//// +////var x: DefaultExportedClass; +//// +////var y = new DefaultExportedClass; +//// +////namespace /**/DefaultExportedClass { +////} + +// The namespace and class do not merge, +// so the namespace should be all alone. + +goTo.marker(); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts new file mode 100644 index 00000000000..a312a277ebb --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts @@ -0,0 +1,21 @@ +/// + +// @Filename: file1.ts +////var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { +//// [|foo|]([|foo|], [|foo|]); +////} + +// @Filename: file2.ts +/////// +////foo(); + + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOfExportDefault.ts b/tests/cases/fourslash/formattingOfExportDefault.ts new file mode 100644 index 00000000000..ff69440b861 --- /dev/null +++ b/tests/cases/fourslash/formattingOfExportDefault.ts @@ -0,0 +1,12 @@ +/// + +////module Foo { +/////*1*/ export default class Test { } +////} +/////*2*/export default function bar() { } + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs(" export default class Test { }") +goTo.marker("2"); +verify.currentLineContentIs("export default function bar() { }") diff --git a/tests/cases/fourslash/formattingOnChainedCallbacks.ts b/tests/cases/fourslash/formattingOnChainedCallbacks.ts index 37fa6ff03f1..b8dbc55d8b6 100644 --- a/tests/cases/fourslash/formattingOnChainedCallbacks.ts +++ b/tests/cases/fourslash/formattingOnChainedCallbacks.ts @@ -13,10 +13,20 @@ //// })/*b*/ ////} +////Promise +//// .then( +//// /*n1*/ +//// ) +//// /*n2*/ +//// .then(); + + goTo.marker('1'); edit.insertLine(''); goTo.marker('2'); verify.currentLineContentIs(' ""'); +edit.insertLine(''); +verify.indentationIs(8); goTo.marker('4'); edit.insertLine(''); goTo.marker('3'); @@ -34,4 +44,9 @@ edit.insert(';'); verify.currentLineContentIs(' "";'); goTo.marker('b'); edit.insert(';'); -verify.currentLineContentIs(' });'); \ No newline at end of file +verify.currentLineContentIs(' });'); + +goTo.marker('n1'); +verify.indentationIs(8); +goTo.marker('n2'); +verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnClasses.ts b/tests/cases/fourslash/formattingOnClasses.ts index 045ee91e427..0c259dae2ec 100644 --- a/tests/cases/fourslash/formattingOnClasses.ts +++ b/tests/cases/fourslash/formattingOnClasses.ts @@ -77,7 +77,9 @@ /////*60*/ private foo ( ns : any ) { /////*61*/ return ns.toString ( ) ; /////*62*/ } -/////*63*/} +/////*63*/ protected bar ( ) { } +/////*64*/ protected static bar2 ( ) { } +/////*65*/} format.document(); goTo.marker("1"); verify.currentLineContentIs("class a {"); @@ -204,4 +206,8 @@ verify.currentLineContentIs(" return ns.toString();"); goTo.marker("62"); verify.currentLineContentIs(" }"); goTo.marker("63"); +verify.currentLineContentIs(" protected bar() { }"); +goTo.marker("64"); +verify.currentLineContentIs(" protected static bar2() { }"); +goTo.marker("65"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName2.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName2.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName2.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName2.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName3.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName3.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName3.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName4.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName4.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName4.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName4.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName5.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName5.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName5.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName6.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName6.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName6.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName7.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName7.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName7.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName8.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName8.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName8.ts diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName9.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionExternamModuleName9.ts rename to tests/cases/fourslash/goToDefinitionExternalModuleName9.ts diff --git a/tests/cases/fourslash/goToDefinitionTypePredicate.ts b/tests/cases/fourslash/goToDefinitionTypePredicate.ts new file mode 100644 index 00000000000..40f1d1eb94c --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionTypePredicate.ts @@ -0,0 +1,16 @@ +/// + +//// /*classDeclaration*/class A {} +//// function f(/*parameterDeclaration*/parameter: any): /*parameterName*/parameter is /*typeReference*/A { +//// return typeof parameter === "string"; +//// } + +goTo.marker('parameterName'); + +goTo.definition(); +verify.caretAtMarker('parameterDeclaration'); + +goTo.marker('typeReference'); + +goTo.definition(); +verify.caretAtMarker('classDeclaration'); \ No newline at end of file diff --git a/tests/cases/fourslash/scriptLexicalStructureBindingPatterns.ts b/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureBindingPatterns.ts rename to tests/cases/fourslash/navigationBarItemsBindingPatterns.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureBindingPatternsInConstructor.ts b/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureBindingPatternsInConstructor.ts rename to tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureEmptyConstructors.ts b/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureEmptyConstructors.ts rename to tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureExports.ts b/tests/cases/fourslash/navigationBarItemsExports.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureExports.ts rename to tests/cases/fourslash/navigationBarItemsExports.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureFunctions.ts b/tests/cases/fourslash/navigationBarItemsFunctions.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureFunctions.ts rename to tests/cases/fourslash/navigationBarItemsFunctions.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureFunctionsBroken.ts b/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureFunctionsBroken.ts rename to tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureFunctionsBroken2.ts b/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureFunctionsBroken2.ts rename to tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureImports.ts b/tests/cases/fourslash/navigationBarItemsImports.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureImports.ts rename to tests/cases/fourslash/navigationBarItemsImports.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItems.ts b/tests/cases/fourslash/navigationBarItemsItems.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItems.ts rename to tests/cases/fourslash/navigationBarItemsItems.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItems2.ts b/tests/cases/fourslash/navigationBarItemsItems2.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItems2.ts rename to tests/cases/fourslash/navigationBarItemsItems2.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsContainsNoAnonymousFunctions.ts b/tests/cases/fourslash/navigationBarItemsItemsContainsNoAnonymousFunctions.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItemsContainsNoAnonymousFunctions.ts rename to tests/cases/fourslash/navigationBarItemsItemsContainsNoAnonymousFunctions.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsExternalModules.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItemsExternalModules.ts rename to tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsExternalModules2.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItemsExternalModules2.ts rename to tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsExternalModules3.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItemsExternalModules3.ts rename to tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsModuleVariables.ts b/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureItemsModuleVariables.ts rename to tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureMissingName1.ts b/tests/cases/fourslash/navigationBarItemsMissingName1.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureMissingName1.ts rename to tests/cases/fourslash/navigationBarItemsMissingName1.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureMissingName2.ts b/tests/cases/fourslash/navigationBarItemsMissingName2.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureMissingName2.ts rename to tests/cases/fourslash/navigationBarItemsMissingName2.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureModules.ts b/tests/cases/fourslash/navigationBarItemsModules.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureModules.ts rename to tests/cases/fourslash/navigationBarItemsModules.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureMultilineStringIdentifiers.ts b/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureMultilineStringIdentifiers.ts rename to tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts diff --git a/tests/cases/fourslash/scriptLexicalStructurePropertiesDefinedInConstructors.ts b/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructurePropertiesDefinedInConstructors.ts rename to tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureSymbols1.ts b/tests/cases/fourslash/navigationBarItemsSymbols1.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureSymbols1.ts rename to tests/cases/fourslash/navigationBarItemsSymbols1.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureSymbols2.ts b/tests/cases/fourslash/navigationBarItemsSymbols2.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureSymbols2.ts rename to tests/cases/fourslash/navigationBarItemsSymbols2.ts diff --git a/tests/cases/fourslash/scriptLexicalStructureSymbols3.ts b/tests/cases/fourslash/navigationBarItemsSymbols3.ts similarity index 100% rename from tests/cases/fourslash/scriptLexicalStructureSymbols3.ts rename to tests/cases/fourslash/navigationBarItemsSymbols3.ts diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts new file mode 100644 index 00000000000..809c127a727 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -0,0 +1,18 @@ +/// + +////export default class /*1*/[|DefaultExportedClass|] { +////} +/////* +//// * Commenting [|DefaultExportedClass|] +//// */ +//// +////var x: /*2*/[|DefaultExportedClass|]; +//// +////var y = new /*3*/[|DefaultExportedClass|]; + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts new file mode 100644 index 00000000000..ddf4b224023 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -0,0 +1,19 @@ +/// + +////export default function /*1*/[|DefaultExportedFunction|]() { +//// return /*2*/[|DefaultExportedFunction|] +////} +/////** +//// * Commenting [|DefaultExportedFunction|] +//// */ +//// +////var x: typeof /*3*/[|DefaultExportedFunction|]; +//// +////var y = /*4*/[|DefaultExportedFunction|](); + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts new file mode 100644 index 00000000000..6f82d96fe5e --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -0,0 +1,25 @@ +/// + +////function /*1*/[|f|]() { +//// return 100; +////} +//// +////export default /*2*/[|f|]; +//// +////var x: typeof /*3*/[|f|]; +//// +////var y = /*4*/[|f|](); +//// +/////** +//// * Commenting [|f|] +//// */ +////namespace /*5*/[|f|] { +//// var local = 100; +////} + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport04.ts b/tests/cases/fourslash/renameForDefaultExport04.ts new file mode 100644 index 00000000000..ba40374e262 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport04.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: foo.ts +////export default class /**/[|DefaultExportedClass|] { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: DefaultExportedClass; +//// +////var y = new DefaultExportedClass; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport05.ts b/tests/cases/fourslash/renameForDefaultExport05.ts new file mode 100644 index 00000000000..099f878bda1 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport05.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: foo.ts +////export default class DefaultExportedClass { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: /**/[|DefaultExportedClass|]; +//// +////var y = new DefaultExportedClass; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport06.ts b/tests/cases/fourslash/renameForDefaultExport06.ts new file mode 100644 index 00000000000..3ec067b7029 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport06.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: foo.ts +////export default class DefaultExportedClass { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: DefaultExportedClass; +//// +////var y = new /**/[|DefaultExportedClass|]; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport07.ts b/tests/cases/fourslash/renameForDefaultExport07.ts new file mode 100644 index 00000000000..b65f348f2a0 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport07.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: foo.ts +////export default function /**/[|DefaultExportedFunction|]() { +//// return DefaultExportedFunction +////} +/////** +//// * Commenting DefaultExportedFunction +//// */ +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport08.ts b/tests/cases/fourslash/renameForDefaultExport08.ts new file mode 100644 index 00000000000..9b3f23db2c1 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport08.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: foo.ts +////export default function DefaultExportedFunction() { +//// return /**/[|DefaultExportedFunction|] +////} +/////** +//// * Commenting DefaultExportedFunction +//// */ +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport09.ts b/tests/cases/fourslash/renameForDefaultExport09.ts new file mode 100644 index 00000000000..bba2e57f49e --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport09.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: foo.ts +////function /**/[|f|]() { +//// return 100; +////} +//// +////export default f; +//// +////var x: typeof f; +//// +////var y = f(); +//// +/////** +//// * Commenting f +//// */ +////namespace f { +//// var local = 100; +////} + +goTo.marker(); +verify.renameInfoSucceeded("f", "f"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameInfoForFunctionExpression01.ts b/tests/cases/fourslash/renameInfoForFunctionExpression01.ts new file mode 100644 index 00000000000..807c4541f3f --- /dev/null +++ b/tests/cases/fourslash/renameInfoForFunctionExpression01.ts @@ -0,0 +1,8 @@ +/// + +////var x = function /**/[|f|](g: any, h: any) { +//// f(f, g); +////} + +goTo.marker(); +verify.renameInfoSucceeded("f"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts new file mode 100644 index 00000000000..a1174d503ed --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -0,0 +1,34 @@ +/// + +////class Foo { +////} +//// +////var x = class /**/Foo { +//// doIt() { +//// return Foo; +//// } +//// +//// static doItStatically() { +//// return Foo; +//// } +////} +//// +////var y = class { +//// getSomeName() { +//// return Foo +//// } +////} + + +// TODO (yuit): Fix up this test when class expressions are supported. +// Just uncomment the below, remove the marker, and add the +// appropriate ranges in the test itself. +goTo.marker(); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); + +////let ranges = test.ranges() +////for (let range of ranges) { +//// goTo.position(range.start); +//// +//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +////} \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts new file mode 100644 index 00000000000..e884783d960 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts @@ -0,0 +1,12 @@ +/// + +////var x = function [|f|](g: any, h: any) { +//// [|f|]([|f|], g); +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts new file mode 100644 index 00000000000..8186611cb64 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts @@ -0,0 +1,18 @@ +/// + +////function f() { +//// +////} +////var x = function [|f|](g: any, h: any) { +//// +//// let helper = function f(): any { f(); } +//// +//// let foo = () => [|f|]([|f|], g); +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/server/tsxIncrementalServer.ts b/tests/cases/fourslash/server/tsxIncrementalServer.ts new file mode 100644 index 00000000000..9ae51406c2f --- /dev/null +++ b/tests/cases/fourslash/server/tsxIncrementalServer.ts @@ -0,0 +1,13 @@ +/// + +//// /**/ + +goTo.marker(); +edit.insert("<"); +edit.insert("div"); +edit.insert(" "); +edit.insert(" id"); +edit.insert("="); +edit.insert("\"foo"); +edit.insert("\""); +edit.insert(">"); diff --git a/tests/cases/fourslash/syntacticClassificationWithErrors.ts b/tests/cases/fourslash/syntacticClassificationWithErrors.ts new file mode 100644 index 00000000000..b4572d3e620 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationWithErrors.ts @@ -0,0 +1,14 @@ +/// + +////class A { +//// a: +////} +////c = + +let c = classification +verify.syntacticClassificationsAre( + c.keyword("class"), c.className("A"), c.punctuation("{"), + c.text("a"), c.punctuation(":"), + c.punctuation("}"), + c.text("c"), c.operator("=") + ); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsDocComment3.ts b/tests/cases/fourslash/syntacticClassificationsDocComment3.ts index bdc7faa470e..6aca8cc415f 100644 --- a/tests/cases/fourslash/syntacticClassificationsDocComment3.ts +++ b/tests/cases/fourslash/syntacticClassificationsDocComment3.ts @@ -14,7 +14,6 @@ verify.syntacticClassificationsAre( c.punctuation("{"), c.keyword("number"), c.comment(" /* } */"), - c.comment("/* } */"), c.keyword("var"), c.text("v"), c.punctuation(";")); diff --git a/tests/cases/fourslash/tsxCompletion1.ts b/tests/cases/fourslash/tsxCompletion1.ts new file mode 100644 index 00000000000..f638b0b6e4f --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion1.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); diff --git a/tests/cases/fourslash/tsxCompletion2.ts b/tests/cases/fourslash/tsxCompletion2.ts new file mode 100644 index 00000000000..d33f9106877 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion2.ts @@ -0,0 +1,15 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props; } +//// } +//// class MyComp { props: { ONE: string; TWO: number } } +//// var x = ; + +goTo.marker(); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); diff --git a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts new file mode 100644 index 00000000000..11ff3afeb8a --- /dev/null +++ b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts @@ -0,0 +1,23 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { } +//// interface ElementAttributesProperty { props; } +//// } +//// /*ct*/class MyClass { +//// props: { +//// /*pt*/foo: string; +//// } +//// } +//// var x = ; +//// var y = ; + +goTo.marker('c'); +goTo.definition(); +verify.caretAtMarker('ct'); + +goTo.marker('p'); +goTo.definition(); +verify.caretAtMarker('pt'); diff --git a/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts new file mode 100644 index 00000000000..bbdf395e478 --- /dev/null +++ b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts @@ -0,0 +1,29 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// /*dt*/div: { +//// /*pt*/name?: string; +//// isOpen?: boolean; +//// }; +//// /*st*/span: { n: string; }; +//// } +//// } +//// var x = ; +//// var y = ; +//// var z =
; + +goTo.marker('ds'); +goTo.definition(); +verify.caretAtMarker('dt'); + +goTo.marker('ss'); +goTo.definition(); +verify.caretAtMarker('st'); + +goTo.marker('ps'); +goTo.definition(); +verify.caretAtMarker('pt'); + diff --git a/tests/cases/fourslash/tsxIncremental.ts b/tests/cases/fourslash/tsxIncremental.ts new file mode 100644 index 00000000000..c901401fff9 --- /dev/null +++ b/tests/cases/fourslash/tsxIncremental.ts @@ -0,0 +1,13 @@ +/// + +//// /**/ + +goTo.marker(); +edit.insert("<"); +edit.insert("div"); +edit.insert(" "); +edit.insert(" id"); +edit.insert("="); +edit.insert("\"foo"); +edit.insert("\""); +edit.insert(">"); diff --git a/tests/cases/fourslash/tsxParsing.ts b/tests/cases/fourslash/tsxParsing.ts new file mode 100644 index 00000000000..e5b2e7ea841 --- /dev/null +++ b/tests/cases/fourslash/tsxParsing.ts @@ -0,0 +1,5 @@ +//// var x =
; +//// var y = /**/x; + +goTo.marker(); +verify.quickInfoExists(); diff --git a/tests/cases/fourslash/tsxRename1.ts b/tests/cases/fourslash/tsxRename1.ts new file mode 100644 index 00000000000..3fb973ec996 --- /dev/null +++ b/tests/cases/fourslash/tsxRename1.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// [|div|]: { +//// name?: string; +//// isOpen?: boolean; +//// }; +//// span: { n: string; }; +//// } +//// } +//// var x = <[|di/*ds*/v|] />; + +goTo.marker('ds'); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename2.ts b/tests/cases/fourslash/tsxRename2.ts new file mode 100644 index 00000000000..d0f5737214b --- /dev/null +++ b/tests/cases/fourslash/tsxRename2.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { +//// [|name|]?: string; +//// isOpen?: boolean; +//// }; +//// span: { n: string; }; +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename3.ts b/tests/cases/fourslash/tsxRename3.ts new file mode 100644 index 00000000000..1ab9c8a5915 --- /dev/null +++ b/tests/cases/fourslash/tsxRename3.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// [|name|]?: string; +//// size?: number; +//// } +//// +//// +//// var x = ; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/underscoreTypings1.ts b/tests/cases/fourslash/underscoreTypings01.ts similarity index 100% rename from tests/cases/fourslash/underscoreTypings1.ts rename to tests/cases/fourslash/underscoreTypings01.ts diff --git a/tests/cases/fourslash/underscoreTyping1.ts b/tests/cases/fourslash/underscoreTypings02.ts similarity index 100% rename from tests/cases/fourslash/underscoreTyping1.ts rename to tests/cases/fourslash/underscoreTypings02.ts diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index a0b361a87f4..1ef10eaa712 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -713,6 +713,24 @@ module m3 { }\ compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); }); + it('Do not move constructors from class to object-literal.', () => { + var source = "class C { public constructor() { } public constructor() { } public constructor() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 0, "class C".length, "var v ="); + + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + }); + + it('Do not move methods called "constructor" from object literal to class', () => { + var source = "var v = { public constructor() { } public constructor() { } public constructor() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); + + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + }); + it('Moving index signatures from class to interface',() => { var source = "class C { public [a: number]: string; public [a: number]: string; public [a: number]: string }" diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 06754a5bbc0..fcce034b227 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -68,6 +68,7 @@ var x = 0;`, `});\n`; runTest("var x = 1;", { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, /*fileName*/ undefined, "NamedModule", output) }); + it("No extra errors for file without extension", () => { runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, "file", /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/[]); }); diff --git a/tests/cases/unittests/versionCache.ts b/tests/cases/unittests/versionCache.ts index 12cf9c1b817..06c2cadbfe9 100644 --- a/tests/cases/unittests/versionCache.ts +++ b/tests/cases/unittests/versionCache.ts @@ -231,7 +231,7 @@ and grew 1cm per day`; }); it("Edit ScriptVersionCache ", () => { - let svc = server.ScriptVersionCache.fromString(testContent); + let svc = server.ScriptVersionCache.fromString(ts.sys, testContent); let checkText = testContent; for (let i = 0; i < iterationCount; i++) { diff --git a/tests/perftsc.ts b/tests/perftsc.ts index e0189896a15..89bff1cc006 100644 --- a/tests/perftsc.ts +++ b/tests/perftsc.ts @@ -10,7 +10,7 @@ if (perftest.hasLogIOFlag()) { var content = perftest.readFile(s); return content !== undefined ? ts.createSourceFile(s, content, v) : undefined; }, - getDefaultLibFilename: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"), + getDefaultLibFileName: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"), writeFile: (f: string, content: string) => { throw new Error("Unexpected operation: writeFile"); }, getCurrentDirectory: () => perftest.getCurrentDirectory(), getCanonicalFileName: (f: string) => ts.sys.useCaseSensitiveFileNames ? f : f.toLowerCase(), @@ -19,8 +19,8 @@ if (perftest.hasLogIOFlag()) { }; var commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag()); - var program = ts.createProgram(commandLine.filenames, commandLine.options, compilerHost); - var fileNames = program.getSourceFiles().map(f => f.filename); + var program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost); + var fileNames = program.getSourceFiles().map(f => f.fileName); perftest.writeIOLog(fileNames); } else {